[PATCH] Off-by-one fix for dl-sysdep.c

Jakub Jelinek jakub@redhat.com
Tue Mar 11 08:57:00 GMT 2003


Hi!

The code later does:
      cp = __mempcpy ((char *) (result + *sz), temp[0].str, temp[0].len);
      *cp = '/';
and so the final '/' is past the end of the malloced buffer.

2003-03-11  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/generic/dl-sysdep.c (_dl_important_hwcaps): If cnt == 1,
	allocate space even for the trailing '/'.  Reported by
	John Reiser <jreiser@BitWagon.com>.

--- libc/sysdeps/generic/dl-sysdep.c.jj	2003-03-06 12:26:22.000000000 -0500
+++ libc/sysdeps/generic/dl-sysdep.c	2003-03-11 02:34:48.000000000 -0500
@@ -338,7 +338,7 @@ _dl_important_hwcaps (const char *platfo
 
   /* Determine the total size of all strings together.  */
   if (cnt == 1)
-    total = temp[0].len;
+    total = temp[0].len + 1;
   else
     {
       total = (1UL << (cnt - 2)) * (temp[0].len + temp[cnt - 1].len + 2);

	Jakub



More information about the Libc-hacker mailing list