summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2006-02-25 13:38:26 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2006-02-25 13:38:26 +0000
commit8ee2a01b688cb3911668295c00b731329070a8a1 (patch)
tree21a0408a0cee0ead46502948772e5e99d30a7b3e /usr.sbin
parent91980a89db21749bba52c0c5439ebf25e7eddab4 (diff)
fix for hostapd_printf() from Andrey Matveev:
---snip--- We allocate some memory with va_start() for storage variable arguments in dynamic mode. va_end() takes care about clearing this memory. Therefore we should be sure, that to each va_start() there corresponds va_end() call. And on error path too. ---snap---
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/hostapd/hostapd.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/usr.sbin/hostapd/hostapd.c b/usr.sbin/hostapd/hostapd.c
index e08c4f525a5..f23d0f43247 100644
--- a/usr.sbin/hostapd/hostapd.c
+++ b/usr.sbin/hostapd/hostapd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hostapd.c,v 1.26 2005/12/18 17:54:12 reyk Exp $ */
+/* $OpenBSD: hostapd.c,v 1.27 2006/02/25 13:38:25 reyk Exp $ */
/*
* Copyright (c) 2004, 2005 Reyk Floeter <reyk@openbsd.org>
@@ -90,25 +90,29 @@ hostapd_printf(const char *fmt, ...)
va_list ap;
size_t n;
- if (fmt == NULL) {
- flush:
- hostapd_log(HOSTAPD_LOG, "%s", printbuf);
- bzero(printbuf, sizeof(printbuf));
- return;
- }
+ if (fmt == NULL)
+ goto flush;
va_start(ap, fmt);
bzero(newfmt, sizeof(newfmt));
if ((n = strlcpy(newfmt, printbuf, sizeof(newfmt))) >= sizeof(newfmt))
- goto flush;
+ goto va_flush;
if (strlcpy(newfmt + n, fmt, sizeof(newfmt) - n) >= sizeof(newfmt) - n)
- goto flush;
+ goto va_flush;
if (vsnprintf(printbuf, sizeof(printbuf), newfmt, ap) == -1)
- goto flush;
+ goto va_flush;
va_end(ap);
if (fmt[0] == '\n')
goto flush;
+
+ return;
+
+ va_flush:
+ va_end(ap);
+ flush:
+ hostapd_log(HOSTAPD_LOG, "%s", printbuf);
+ bzero(printbuf, sizeof(printbuf));
}
void