Date: Thu, 12 Sep 2002 12:02:45 +0400 (MSD) From: Maxim Konovalov <maxim@macomnet.ru> To: freebsd-current@freebsd.org Cc: billf@freebsd.org Subject: vsnprintf(3) memory leak patch, misc/26044 and bin/36175 Message-ID: <20020912115723.X95514-100000@news1.macomnet.ru>
next in thread | raw e-mail | index | archive | help
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:maxim@macomnet.ru To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020912115723.X95514-100000>