Fix an off-by-one in asprintf and vasprintf. The return of vsnprintf is
the number of bytes *not* including the terminating '\0'. The size
argument to vsnprintf is the number of bytes *including* the terminating
'\0'.
diff -u klibc-0.188/klibc/asprintf.c udev/klibc-0.188/klibc/asprintf.c
--- klibc-0.188/klibc/asprintf.c 2004-10-22 12:07:22.678906352 -0600
+++ udev/klibc-0.188/klibc/asprintf.c 2004-10-22 12:08:03.859645928 -0600
@@ -16,10 +16,10 @@
va_start(ap, format);
va_copy(ap1, ap);
- bytes = vsnprintf(NULL, 0, format, ap1);
+ bytes = vsnprintf(NULL, 0, format, ap1) + 1;
va_end(ap1);
- *bufp = p = malloc(bytes+1);
+ *bufp = p = malloc(bytes);
if ( !p )
return -1;
diff -u klibc-0.188/klibc/vasprintf.c udev/klibc-0.188/klibc/vasprintf.c
--- klibc-0.188/klibc/vasprintf.c 2004-10-22 12:07:41.994969864 -0600
+++ udev/klibc-0.188/klibc/vasprintf.c 2004-10-22 12:08:23.497660496 -0600
@@ -14,10 +14,10 @@
va_copy(ap1, ap);
- bytes = vsnprintf(NULL, 0, format, ap1);
+ bytes = vsnprintf(NULL, 0, format, ap1) + 1;
va_end(ap1);
- *bufp = p = malloc(bytes+1);
+ *bufp = p = malloc(bytes);
if ( !p )
return -1;
--
Thayne Harbaugh
Linux Networx
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url :
http://www.zytor.com/pipermail/klibc/attachments/20041022/74f45458/attachment.bin