Hello -current,

Our vsnprintf(3) has a memory leak, take a look at

http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/36175 and

http://www.freebsd.org/cgi/query-pr.cgi?pr=misc/26044

for details.

Any objections against a patch below (from OpenBSD)?

Index: libc/stdio/vsnprintf.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/stdio/vsnprintf.c,v
retrieving revision 1.20
diff -u -r1.20 vsnprintf.c
--- libc/stdio/vsnprintf.c      6 Sep 2002 11:23:56 -0000       1.20
+++ libc/stdio/vsnprintf.c      12 Sep 2002 07:55:53 -0000
@@ -50,6 +50,7 @@
 {
        size_t on;
        int ret;
+       char dummy;
        FILE f;
        struct __sFILEX ext;

@@ -58,6 +59,11 @@
                n--;
        if (n > INT_MAX)
                n = INT_MAX;
+       /* Stdio internals do not deal correctly with zero length buffer */
+       if (n == 0) {
+                str = &dummy;
+                n = 1;
+       }
        f._file = -1;
        f._flags = __SWR | __SSTR;
        f._bf._base = f._p = (unsigned char *)str;

%%%

-- 
Maxim Konovalov, MAcomnet, Internet Dept., system engineer
phone: +7 (095) 796-9079, mailto:[EMAIL PROTECTED]



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to