]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
stdbuf: fix to stop -i option causing an assertion
authorPádraig Brady <P@draigBrady.com>
Sat, 27 Jun 2009 00:48:49 +0000 (01:48 +0100)
committerPádraig Brady <P@draigBrady.com>
Sat, 27 Jun 2009 01:21:43 +0000 (02:21 +0100)
* src/stdbuf.c (main): Fix the array bounds check in the assert
* tests/misc/stdbuf: Add a test for all standard streams

src/stdbuf.c
tests/misc/stdbuf

index 89f2242ded9cff80408b1dd898bf53f2c7cd7a68..5da934191add2c6884587c7bd27e1f3606a96665 100644 (file)
@@ -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++;
index 6f79e771f9a20a898b762d3cc9b35f68b7fbdb87..30aa5898e3b8a799caa95be6ce30361df0bdff07 100755 (executable)
@@ -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