From owner-freebsd-current Thu Sep 12 1: 2:52 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B8D0F37B400; Thu, 12 Sep 2002 01:02:48 -0700 (PDT) Received: from relay1.macomnet.ru (relay1.macomnet.ru [195.128.64.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4FCEB43E72; Thu, 12 Sep 2002 01:02:47 -0700 (PDT) (envelope-from maxim@macomnet.ru) Received: from news1.macomnet.ru (news1.macomnet.ru [195.128.64.14]) by relay1.macomnet.ru (8.11.6/8.11.6) with ESMTP id g8C82jO928243; Thu, 12 Sep 2002 12:02:45 +0400 (MSD) Date: Thu, 12 Sep 2002 12:02:45 +0400 (MSD) From: Maxim Konovalov 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> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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