]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(main): Fix off-by-one error.
authorJim Meyering <jim@meyering.net>
Sun, 3 Apr 2005 13:12:53 +0000 (13:12 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 3 Apr 2005 13:12:53 +0000 (13:12 +0000)
pr -$(perl -e 'print "0"x63 . 1') would write one byte beyond the
end of a malloc'd buffer.

src/pr.c

index c5f5f28e613ae7f1a75a44bc5bfc79512a2b6afa..886448b8c1f38f9805158f7babf2f3db90e6ca8d 100644 (file)
--- a/src/pr.c
+++ b/src/pr.c
@@ -892,7 +892,7 @@ main (int argc, char **argv)
       if (ISDIGIT (c))
        {
          /* Accumulate column-count digits specified via old-style options. */
-         if (n_digits == n_alloc)
+         if (n_digits + 1 >= n_alloc)
            column_count_string
              = x2nrealloc (column_count_string, &n_alloc,
                            sizeof *column_count_string);