diff options
author | 2001-09-05 22:32:27 +0000 | |
---|---|---|
committer | 2001-09-05 22:32:27 +0000 | |
commit | 24766c5400032a2369be118d2414a7986b46bee0 (patch) | |
tree | 8a4a6c3337382440d16aeab559efaa74df34c5e7 /lib | |
parent | sparc64 uses new binutils. (diff) | |
download | wireguard-openbsd-24766c5400032a2369be118d2414a7986b46bee0.tar.xz wireguard-openbsd-24766c5400032a2369be118d2414a7986b46bee0.zip |
make sure that va_start() has matching va_end()
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/stdio/asprintf.c | 7 | ||||
-rw-r--r-- | lib/libocurses/ctrace.c | 4 | ||||
-rw-r--r-- | lib/libutil/scsi.c | 33 |
3 files changed, 31 insertions, 13 deletions
diff --git a/lib/libc/stdio/asprintf.c b/lib/libc/stdio/asprintf.c index fd0ba320c8f..f08e6c96f42 100644 --- a/lib/libc/stdio/asprintf.c +++ b/lib/libc/stdio/asprintf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asprintf.c,v 1.6 1998/10/16 16:11:55 millert Exp $ */ +/* $OpenBSD: asprintf.c,v 1.7 2001/09/05 22:32:33 deraadt Exp $ */ /* * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com> @@ -28,7 +28,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: asprintf.c,v 1.6 1998/10/16 16:11:55 millert Exp $"; +static char rcsid[] = "$OpenBSD: asprintf.c,v 1.7 2001/09/05 22:32:33 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #include <stdio.h> @@ -70,14 +70,15 @@ asprintf(str, fmt, va_alist) if (ret == -1) goto err; *f._p = '\0'; - va_end(ap); _base = realloc(f._bf._base, ret + 1); if (_base == NULL) goto err; *str = (char *)_base; + va_end(ap); return (ret); err: + va_end(ap); if (f._bf._base) { free(f._bf._base); f._bf._base = NULL; diff --git a/lib/libocurses/ctrace.c b/lib/libocurses/ctrace.c index 4f53906cc5e..5f659454f95 100644 --- a/lib/libocurses/ctrace.c +++ b/lib/libocurses/ctrace.c @@ -67,8 +67,10 @@ __CTRACE(fmt, va_alist) #endif if (tracefp == NULL) tracefp = fopen(TFILE, "w"); - if (tracefp == NULL) + if (tracefp == NULL) { + va_end(ap); return; + } (void)vfprintf(tracefp, fmt, ap); va_end(ap); (void)fflush(tracefp); diff --git a/lib/libutil/scsi.c b/lib/libutil/scsi.c index f5af3dbfd39..b7a6d66df36 100644 --- a/lib/libutil/scsi.c +++ b/lib/libutil/scsi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi.c,v 1.2 1996/07/31 09:25:48 niklas Exp $ */ +/* $OpenBSD: scsi.c,v 1.3 2001/09/05 22:32:36 deraadt Exp $ */ /* Copyright (c) 1994 HD Associates * (contact: dufault@hda.com) @@ -355,31 +355,42 @@ char *fmt, va_list ap) int scsireq_decode(scsireq_t *scsireq, char *fmt, ...) { va_list ap; + int ret; + va_start (ap, fmt); - return do_buff_decode(scsireq->databuf, (size_t)scsireq->datalen, + ret = do_buff_decode(scsireq->databuf, (size_t)scsireq->datalen, 0, 0, fmt, ap); + va_end (ap); + return (ret); } int scsireq_decode_visit(scsireq_t *scsireq, char *fmt, void (*arg_put)(void *, int , void *, int, char *), void *puthook) { va_list ap; - return do_buff_decode(scsireq->databuf, (size_t)scsireq->datalen, + int ret; + + ret = do_buff_decode(scsireq->databuf, (size_t)scsireq->datalen, arg_put, puthook, fmt, ap); + va_end (ap); + return (ret); } int scsireq_buff_decode(u_char *buff, size_t len, char *fmt, ...) { va_list ap; + int ret; + va_start (ap, fmt); - return do_buff_decode(buff, len, 0, 0, fmt, ap); + ret = do_buff_decode(buff, len, 0, 0, fmt, ap); + va_end (ap); + return (ret); } int scsireq_buff_decode_visit(u_char *buff, size_t len, char *fmt, void (*arg_put)(void *, int, void *, int, char *), void *puthook) { - va_list ap; - return do_buff_decode(buff, len, arg_put, puthook, fmt, ap); + return do_buff_decode(buff, len, arg_put, puthook, fmt, NULL); } /* next_field: Return the next field in a command specifier. This @@ -789,6 +800,7 @@ scsireq_t *scsireq_build(scsireq_t *scsireq, if (do_encode(scsireq->cmd, CMD_BUFLEN, &cmdlen, 0, 0, cmd_spec, ap) == -1) return 0; + va_end (ap); scsireq->cmdlen = cmdlen; return scsireq; @@ -837,14 +849,17 @@ scsireq_t int scsireq_encode(scsireq_t *scsireq, char *fmt, ...) { va_list ap; + int ret; if (scsireq == 0) return 0; va_start(ap, fmt); - return do_encode(scsireq->databuf, + ret = do_encode(scsireq->databuf, scsireq->datalen, 0, 0, 0, fmt, ap); + va_end (ap); + return (ret); } int scsireq_buff_encode_visit(u_char *buff, size_t len, char *fmt, @@ -852,7 +867,7 @@ int scsireq_buff_encode_visit(u_char *buff, size_t len, char *fmt, { va_list ap; return do_encode(buff, len, 0, - arg_get, gethook, fmt, ap); + arg_get, gethook, fmt, ap); } int scsireq_encode_visit(scsireq_t *scsireq, char *fmt, @@ -860,7 +875,7 @@ int scsireq_encode_visit(scsireq_t *scsireq, char *fmt, { va_list ap; return do_encode(scsireq->databuf, scsireq->datalen, 0, - arg_get, gethook, fmt, ap); + arg_get, gethook, fmt, ap); } FILE *scsi_debug_output(char *s) |