>>> CID
1539212: Control flow issues (NO_EFFECT)
>>> This greater-than-or-equal-to-zero comparison of an unsigned value is always true. "p >= 0UL".
216 while (p >= 0 && output[p] == '\n') {
This is a real problem in the unlikely event that the output contains
only newlines.
Fix the issue by using a pointer and add a test to cover this case.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15438
Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
const char *t = script->output == NULL ? "" : script->output;
size_t len = strlen(t);
char output[len+1];
- size_t p;
char *t1, *t2;
strlcpy(output, t, sizeof(output));
* Strip trailing newlines, they are clutter and
* interfere with multi-line detection
*/
- p = len - 1;
- while (p >= 0 && output[p] == '\n') {
- output[p] = '\0';
- p--;
+ t1 = output + len - 1;
+ while (t1 >= output && *t1 == '\n') {
+ *t1 = '\0';
+ t1--;
}
/* If the output is a single line then print it inline */
printf 'No trailing newline'
exit 0
;;
+"verbosenewlinesonly")
+ cat <<EOF
+
+
+
+EOF
+ exit 0
+ ;;
"verbosefailure") echo "args: $*"; exit 1 ;;
"verbosemultilinefailure")
cat <<EOF
EOF
simple_test status random verbosemultilinenonl
+ok_null
+simple_test run 10 random verbosenewlinesonly
+
+ok <<EOF
+01.disabled DISABLED
+02.enabled OK DURATION DATETIME
+ OUTPUT:
+EOF
+simple_test status random verbosenewlinesonly
+
required_result 8 <<EOF
Event verbosemultilinefailure in random failed
EOF