Author: das Date: Sat Apr 21 06:08:29 2012 New Revision: 234529 URL: http://svn.freebsd.org/changeset/base/234529
Log: Ensure that the {,v}swprintf functions always null-terminate the output string, even if an encoding error or malloc failure occurs. Modified: head/lib/libc/stdio/vswprintf.c Modified: head/lib/libc/stdio/vswprintf.c ============================================================================== --- head/lib/libc/stdio/vswprintf.c Sat Apr 21 06:08:02 2012 (r234528) +++ head/lib/libc/stdio/vswprintf.c Sat Apr 21 06:08:29 2012 (r234529) @@ -66,6 +66,7 @@ vswprintf_l(wchar_t * __restrict s, size 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 */ @@ -74,6 +75,7 @@ vswprintf_l(wchar_t * __restrict s, size sverrno = errno; free(f._bf._base); errno = sverrno; + *s = L'\0'; return (-1); } *f._p = '\0'; @@ -87,6 +89,7 @@ vswprintf_l(wchar_t * __restrict s, size free(f._bf._base); if (nwc == (size_t)-1) { errno = EILSEQ; + *s = L'\0'; return (-1); } if (nwc == n) { _______________________________________________ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"