fbuf was used uninitialized, which meant we printed garbage data from the heap when flags was 0. Update the test to prevent regressions.
Fixes: bcac9c40 Signed-off-by: Eric Blake <[email protected]> --- plugins/sh/sh.c | 2 ++ tests/test-shell.sh | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/plugins/sh/sh.c b/plugins/sh/sh.c index aeb01918..737c38cf 100644 --- a/plugins/sh/sh.c +++ b/plugins/sh/sh.c @@ -453,6 +453,8 @@ flags_string (uint32_t flags, char *buf, size_t len) { bool comma = false; + buf[0] = '\0'; + if (flags & NBDKIT_FLAG_FUA) flag_append ("fua", &comma, &buf, &len); diff --git a/tests/test-shell.sh b/tests/test-shell.sh index a744b275..53c0b943 100755 --- a/tests/test-shell.sh +++ b/tests/test-shell.sh @@ -42,6 +42,11 @@ case "$1" in ;; pwrite) + case $5 in + '' | fua) ;; + *) echo "garbage flags: '$5'" >&2 + exit 1; + esac dd oflag=seek_bytes conv=notrunc seek=$4 of=$f || exit 1 ;; can_write) @@ -54,6 +59,11 @@ case "$1" in ;; trim) + case $5 in + '' | fua) ;; + *) echo "garbage flags: '$5'" >&2 + exit 1; + esac fallocate -p -o $4 -l $3 -n $f ;; can_trim) @@ -62,6 +72,11 @@ case "$1" in ;; zero) + case $5 in + '' | fua | may_trim | fua,may_trim ) ;; + *) echo "garbage flags: '$5'" >&2 + exit 1; + esac fallocate -z -o $4 -l $3 -n $f ;; can_zero) -- 2.20.1 _______________________________________________ Libguestfs mailing list [email protected] https://www.redhat.com/mailman/listinfo/libguestfs
