diff options
author | Trond Norbye <Trond.Norbye@gmail.com> | 2010-02-22 22:09:28 +0100 |
---|---|---|
committer | Dustin Sallings <dustin@spy.net> | 2010-02-22 13:15:45 -0800 |
commit | 7fc4fcc926ec2be9c762e44c49ef41fa7739b2e4 (patch) | |
tree | be64a9ab111b981f21010fa0c44a2f61562a68ed /util.c | |
parent | a0a70329033f3f88de500b8f098e989247dd8f91 (diff) | |
download | memcached-7fc4fcc926ec2be9c762e44c49ef41fa7739b2e4.tar.gz |
Fix potential buffer overflow in vperror
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -92,11 +92,13 @@ bool safe_strtol(const char *str, int32_t *out) { void vperror(const char *fmt, ...) { int old_errno = errno; - char buf[80]; + char buf[1024]; va_list ap; va_start(ap, fmt); - vsnprintf(buf, sizeof(buf), fmt, ap); + if (vsnprintf(buf, sizeof(buf), fmt, ap) == -1) { + buf[sizeof(buf) - 1] = '\0'; + } va_end(ap); errno = old_errno; |