diff options
author | Brad Smith <brad@cvs.openbsd.org> | 2006-11-26 15:25:15 +0000 |
---|---|---|
committer | Brad Smith <brad@cvs.openbsd.org> | 2006-11-26 15:25:15 +0000 |
commit | 6d86d88d3b1f3a03974f0f16549139d0d8c79f0e (patch) | |
tree | 57fab3eeaa11534590c8b8aeb87729ef206e1f7c /lib/libevent/buffer.c | |
parent | 4b637a3eacaa25dbf777e1d7e1b3337c0c34ccc9 (diff) |
fix a potential problem in multiple handling of va_list; use va_copy instead.
From Niels Provos via the libevent SVN, by Alejo.
ok deraadt@
Diffstat (limited to 'lib/libevent/buffer.c')
-rw-r--r-- | lib/libevent/buffer.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/libevent/buffer.c b/lib/libevent/buffer.c index 36d04599005..a258b369d68 100644 --- a/lib/libevent/buffer.c +++ b/lib/libevent/buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buffer.c,v 1.10 2006/03/18 20:23:42 brad Exp $ */ +/* $OpenBSD: buffer.c,v 1.11 2006/11/26 15:25:14 brad Exp $ */ /* * Copyright (c) 2002, 2003 Niels Provos <provos@citi.umich.edu> @@ -134,17 +134,23 @@ evbuffer_add_vprintf(struct evbuffer *buf, const char *fmt, va_list ap) size_t space; size_t oldoff = buf->off; int sz; + va_list aq; for (;;) { - buffer = buf->buffer + buf->off; + buffer = (char *)buf->buffer + buf->off; space = buf->totallen - buf->misalign - buf->off; + va_copy(aq, ap); + #ifdef WIN32 - sz = vsnprintf(buffer, space - 1, fmt, ap); + sz = vsnprintf(buffer, space - 1, fmt, aq); buffer[space - 1] = '\0'; #else - sz = vsnprintf(buffer, space, fmt, ap); + sz = vsnprintf(buffer, space, fmt, aq); #endif + + va_end(aq); + if (sz == -1) return (-1); if (sz < space) { |