diff options
| author | Maxim Konovalov <maxim@FreeBSD.org> | 2002-09-23 06:58:17 +0000 |
|---|---|---|
| committer | Maxim Konovalov <maxim@FreeBSD.org> | 2002-09-23 06:58:17 +0000 |
| commit | 77a5659f0752189c3e2f23e2799f144776709497 (patch) | |
| tree | 8e201ebbe4b32f2bf324d485ffa6221594f2d699 /lib/libc/stdio/vsnprintf.c | |
| parent | 9bec5b48498b4ca3123f09f84a9ba053671fa2d6 (diff) | |
Notes
Diffstat (limited to 'lib/libc/stdio/vsnprintf.c')
| -rw-r--r-- | lib/libc/stdio/vsnprintf.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/libc/stdio/vsnprintf.c b/lib/libc/stdio/vsnprintf.c index b8e4c8c271cd..6b20a2dd5b41 100644 --- a/lib/libc/stdio/vsnprintf.c +++ b/lib/libc/stdio/vsnprintf.c @@ -54,6 +54,7 @@ vsnprintf(str, n, fmt, ap) { size_t on; int ret; + char dummy; FILE f; on = n; @@ -61,6 +62,11 @@ vsnprintf(str, n, fmt, ap) 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; |
