summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorTrond Norbye <Trond.Norbye@gmail.com>2010-02-22 22:09:28 +0100
committerDustin Sallings <dustin@spy.net>2010-02-22 13:15:45 -0800
commit7fc4fcc926ec2be9c762e44c49ef41fa7739b2e4 (patch)
treebe64a9ab111b981f21010fa0c44a2f61562a68ed /util.c
parenta0a70329033f3f88de500b8f098e989247dd8f91 (diff)
downloadmemcached-7fc4fcc926ec2be9c762e44c49ef41fa7739b2e4.tar.gz
Fix potential buffer overflow in vperror
Diffstat (limited to 'util.c')
-rw-r--r--util.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/util.c b/util.c
index f935fac..cc2da65 100644
--- a/util.c
+++ b/util.c
@@ -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;