aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2025-06-28 08:07:54 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2025-06-28 21:00:41 -0700
commit69b07cc58de0a86f7b06d6709049077c6bd486ea (patch)
tree8032a5b52da7a5a4cddc07411a5c2de4695a4ccf
parentod: fix theoretical size_t malloc overflow (diff)
downloadcoreutils-69b07cc58de0a86f7b06d6709049077c6bd486ea.tar.gz
coreutils-69b07cc58de0a86f7b06d6709049077c6bd486ea.zip
od: fix another off-by-one issue with --strings
* src/od.c (main): Fix off-by-one error in string_min limit.
-rw-r--r--src/od.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/od.c b/src/od.c
index 7306b0f9a..439f71e5b 100644
--- 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;