]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix ld-address format-truncation error.
authorJoseph Myers <joseph@codesourcery.com>
Wed, 11 Jan 2017 13:59:01 +0000 (13:59 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Wed, 11 Jan 2017 13:59:01 +0000 (13:59 +0000)
With the elf/sotruss-lib.c failure fixed, building 64-bit glibc with
GCC mainline fails with another format-truncation error in
locale/programs/ld-address.c, where 11 bytes are allocated for a
buffer to print a long int value.

This patch changes that code to allocate 21 bytes.  Treating this
value as signed is questionable and I don't think large values are
actually useful here, but I think those can be considered as instances
of bug 21036 which I've filed for overflow checks for numeric values
in localedef in general, and don't need to be addressed to fix the
build.

Tested with GCC mainline with compilation for aarch64 with
build-many-glibcs.py, and with glibc testsuite for x86_64 (built with
GCC 6).

(Note that while this fixes the build of 64-bit glibc with GCC
mainline, further fixes will be needed to get the testsuite building
with GCC mainline again.)

* locale/programs/ld-address.c (INT_STR_ELEM): Increase size of
buffer used to print long int value.

ChangeLog
locale/programs/ld-address.c

index fe612a80b9c06f4fe501b282c75fd9288de7b434..8e784b8fd898a9a82f7663cccf1759635db45843 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2017-01-11  Joseph Myers  <joseph@codesourcery.com>
 
+       * locale/programs/ld-address.c (INT_STR_ELEM): Increase size of
+       buffer used to print long int value.
+
        * elf/sotruss-lib.c (init): Increase space allocated for pid by
        one byte.  Print it with %ld, cast to long int.
 
index 3c13e68af3395bb6ed5a0c0093f0e634c1f5ab77..2488a5ce5cb474980d407f1536737ce18bf0b6f7 100644 (file)
@@ -485,8 +485,8 @@ address_read (struct linereader *ldfile, struct localedef_t *result,
                address->cat = arg->val.str.startmb;                          \
              else                                                            \
                {                                                             \
-                 char *numbuf = (char *) xmalloc (11);                       \
-                 snprintf (numbuf, 11, "%ld", arg->val.num);                 \
+                 char *numbuf = (char *) xmalloc (21);                       \
+                 snprintf (numbuf, 21, "%ld", arg->val.num);                 \
                  address->cat = numbuf;                                      \
                }                                                             \
            }                                                                 \