]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
od: fix another off-by-one issue with --strings
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 28 Jun 2025 15:07:54 +0000 (08:07 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 29 Jun 2025 04:00:41 +0000 (21:00 -0700)
* src/od.c (main): Fix off-by-one error in string_min limit.

src/od.c

index 7306b0f9ad4b7b59aa18b71158302114ad427eca..439f71e5b50a3f71706d8f35c9ff895ee70c4164 100644 (file)
--- a/src/od.c
+++ b/src/od.c
@@ -1738,10 +1738,10 @@ main (int argc, char **argv)
               if (s_err != LONGINT_OK)
                 xstrtol_fatal (s_err, oi, c, long_options, optarg);
 
-              /* The minimum string length may be no larger than
+              /* The minimum string length must be less than
                  MIN (IDX_MAX, SIZE_MAX), since we may allocate a
-                 buffer of this size.  */
-              if (MIN (IDX_MAX, SIZE_MAX) < tmp)
+                 buffer of this size + 1.  */
+              if (MIN (IDX_MAX, SIZE_MAX) <= tmp)
                 error (EXIT_FAILURE, 0, _("%s is too large"), quote (optarg));
 
               string_min = tmp;