From owner-svn-src-stable-7@FreeBSD.ORG Tue Apr 24 03:59:14 2012 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1A9AE1065673; Tue, 24 Apr 2012 03:59:14 +0000 (UTC) (envelope-from das@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 059858FC1A; Tue, 24 Apr 2012 03:59:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3O3xDe6029351; Tue, 24 Apr 2012 03:59:13 GMT (envelope-from das@svn.freebsd.org) Received: (from das@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3O3xDg4029349; Tue, 24 Apr 2012 03:59:13 GMT (envelope-from das@svn.freebsd.org) Message-Id: <201204240359.q3O3xDg4029349@svn.freebsd.org> From: David Schultz Date: Tue, 24 Apr 2012 03:59:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234633 - stable/7/lib/libc/stdio X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Apr 2012 03:59:14 -0000 Author: das Date: Tue Apr 24 03:59:13 2012 New Revision: 234633 URL: http://svn.freebsd.org/changeset/base/234633 Log: MFC r234529: Ensure that the {,v}swprintf functions always null-terminate the output string, even if an encoding error or malloc failure occurs. Modified: stable/7/lib/libc/stdio/vswprintf.c Directory Properties: stable/7/lib/libc/ (props changed) Modified: stable/7/lib/libc/stdio/vswprintf.c ============================================================================== --- stable/7/lib/libc/stdio/vswprintf.c Tue Apr 24 03:56:45 2012 (r234632) +++ stable/7/lib/libc/stdio/vswprintf.c Tue Apr 24 03:59:13 2012 (r234633) @@ -61,6 +61,7 @@ vswprintf(wchar_t * __restrict s, size_t f._bf._base = f._p = (unsigned char *)malloc(128); if (f._bf._base == NULL) { errno = ENOMEM; + *s = L'\0'; return (-1); } f._bf._size = f._w = 127; /* Leave room for the NUL */ @@ -71,6 +72,7 @@ vswprintf(wchar_t * __restrict s, size_t sverrno = errno; free(f._bf._base); errno = sverrno; + *s = L'\0'; return (-1); } *f._p = '\0'; @@ -84,6 +86,7 @@ vswprintf(wchar_t * __restrict s, size_t free(f._bf._base); if (nwc == (size_t)-1) { errno = EILSEQ; + *s = L'\0'; return (-1); } if (nwc == n) {