diff mbox

Fix ld-address format-truncation error

Message ID alpine.DEB.2.20.1701100230190.8116@digraph.polyomino.org.uk
State New
Headers show

Commit Message

Joseph Myers Jan. 10, 2017, 2:30 a.m. UTC
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.)

2017-01-10  Joseph Myers  <joseph@codesourcery.com>

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

Comments

Joseph Myers Jan. 11, 2017, 1:59 p.m. UTC | #1
Now committed.
diff mbox

Patch

diff --git a/locale/programs/ld-address.c b/locale/programs/ld-address.c
index 3c13e68..2488a5c 100644
--- a/locale/programs/ld-address.c
+++ b/locale/programs/ld-address.c
@@ -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;				      \
 		}							      \
 	    }								      \