]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
bug#7213: [PATCH] sort: fix buffer overrun on 32-bit hosts when warning re obsolete...
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 14 Oct 2010 07:12:23 +0000 (00:12 -0700)
committerJim Meyering <meyering@redhat.com>
Thu, 14 Oct 2010 09:39:14 +0000 (11:39 +0200)
* src/sort.c (key_warnings): Local buffer should be of size
INT_BUFSIZE_BOUND (uintmax_t), not INT_BUFSIZE_BOUND (sword).
This bug was discovered by running 'make check' on a 32-bit
Solaris 8 sparc host, using Sun cc.  I saw several other instances
of invoking umaxtostr on a buffer declared to be of size
INT_BUFSIZE_BOUND (VAR), and these instances should at some point
be replaced by INT_BUFSIZE_BOUND (uintmax_t) too, as that's a
less error-prone style.

src/sort.c

index c155edadbc5808a258cd0e4568bb3b796ce2a730..7e25f6a0b3ce18ce6b7a8d9f565c577108fbc804 100644 (file)
@@ -2320,7 +2320,7 @@ key_warnings (struct keyfield const *gkey, bool gkey_only)
         {
           size_t sword = key->sword;
           size_t eword = key->eword;
-          char tmp[INT_BUFSIZE_BOUND (sword)];
+          char tmp[INT_BUFSIZE_BOUND (uintmax_t)];
           /* obsolescent syntax +A.x -B.y is equivalent to:
                -k A+1.x+1,B.y   (when y = 0)
                -k A+1.x+1,B+1.y (when y > 0)  */