From: Pádraig Brady Date: Sat, 27 Jun 2009 00:48:49 +0000 (+0100) Subject: stdbuf: fix to stop -i option causing an assertion X-Git-Tag: v7.5~81 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1c16c9598e67e0db641af8b85abf8c009e3a9226;p=thirdparty%2Fcoreutils.git stdbuf: fix to stop -i option causing an assertion * src/stdbuf.c (main): Fix the array bounds check in the assert * tests/misc/stdbuf: Add a test for all standard streams --- diff --git a/src/stdbuf.c b/src/stdbuf.c index 89f2242ded..5da934191a 100644 --- a/src/stdbuf.c +++ b/src/stdbuf.c @@ -319,7 +319,7 @@ main (int argc, char **argv) case 'i': case 'o': opt_fileno = optc_to_fileno (c); - assert (0 < opt_fileno && opt_fileno <= ARRAY_CARDINALITY (stdbuf)); + assert (0 <= opt_fileno && opt_fileno < ARRAY_CARDINALITY (stdbuf)); stdbuf[opt_fileno].optc = c; while (c_isspace (*optarg)) optarg++; diff --git a/tests/misc/stdbuf b/tests/misc/stdbuf index 6f79e771f9..30aa5898e3 100755 --- a/tests/misc/stdbuf +++ b/tests/misc/stdbuf @@ -41,6 +41,7 @@ stdbuf -oL true || fail=1 # verify line buffered syntax stdbuf -ol true && fail=1 # Capital 'L' required stdbuf -o$SIZE_OFLOW true && fail=1 # size too large stdbuf -iL true && fail=1 # line buffering stdin disallowed +stdbuf -i0 -o0 -e0 true || fail=1 #check all files # Ensure line buffering stdout takes effect printf '1\n' > exp