aboutsummaryrefslogtreecommitdiff
path: root/cddl/contrib/opensolaris/lib/libdtrace
diff options
context:
space:
mode:
authorGeorge V. Neville-Neil <gnn@FreeBSD.org>2016-10-11 16:12:12 +0000
committerGeorge V. Neville-Neil <gnn@FreeBSD.org>2016-10-11 16:12:12 +0000
commit956c2a73cd66383d7209d5d3fabea2a6381fa88d (patch)
treeab5495bbb3ecc3d38b08a52a53e4b38334721863 /cddl/contrib/opensolaris/lib/libdtrace
parentc3ad6e4f3e37a2907323764c90327ec0650ccd73 (diff)
downloadsrc-956c2a73cd66383d7209d5d3fabea2a6381fa88d.tar.gz
src-956c2a73cd66383d7209d5d3fabea2a6381fa88d.zip
Corrected non-portable reuse of va_list in dt_printf()
Submitted by: Graeme Jenkinson Reviewed by: markj MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D8157
Notes
Notes: svn path=/head/; revision=307044
Diffstat (limited to 'cddl/contrib/opensolaris/lib/libdtrace')
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c
index 72fd08aee2c1..2d8c24a0a596 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c
@@ -581,6 +581,7 @@ int
dt_printf(dtrace_hdl_t *dtp, FILE *fp, const char *format, ...)
{
va_list ap;
+ va_list ap2;
int n;
#ifndef illumos
@@ -605,11 +606,13 @@ dt_printf(dtrace_hdl_t *dtp, FILE *fp, const char *format, ...)
len = dtp->dt_sprintf_buflen - len;
assert(len >= 0);
- if ((n = vsnprintf(buf, len, format, ap)) < 0)
+ va_copy(ap2, ap);
+ if ((n = vsnprintf(buf, len, format, ap2)) < 0)
n = dt_set_errno(dtp, errno);
+ va_end(ap2);
va_end(ap);
-
+
return (n);
}
@@ -640,11 +643,14 @@ dt_printf(dtrace_hdl_t *dtp, FILE *fp, const char *format, ...)
dtp->dt_buffered_buf[0] = '\0';
}
- if ((needed = vsnprintf(NULL, 0, format, ap)) < 0) {
+ va_copy(ap2, ap);
+ if ((needed = vsnprintf(NULL, 0, format, ap2)) < 0) {
rval = dt_set_errno(dtp, errno);
+ va_end(ap2);
va_end(ap);
return (rval);
}
+ va_end(ap2);
if (needed == 0) {
va_end(ap);
@@ -670,12 +676,15 @@ dt_printf(dtrace_hdl_t *dtp, FILE *fp, const char *format, ...)
dtp->dt_buffered_size <<= 1;
}
+ va_copy(ap2, ap);
if (vsnprintf(&dtp->dt_buffered_buf[dtp->dt_buffered_offs],
- avail, format, ap) < 0) {
+ avail, format, ap2) < 0) {
rval = dt_set_errno(dtp, errno);
+ va_end(ap2);
va_end(ap);
return (rval);
}
+ va_end(ap2);
dtp->dt_buffered_offs += needed;
assert(dtp->dt_buffered_buf[dtp->dt_buffered_offs] == '\0');
@@ -683,8 +692,10 @@ dt_printf(dtrace_hdl_t *dtp, FILE *fp, const char *format, ...)
return (0);
}
- n = vfprintf(fp, format, ap);
+ va_copy(ap2, ap);
+ n = vfprintf(fp, format, ap2);
fflush(fp);
+ va_end(ap2);
va_end(ap);
if (n < 0) {