From owner-svn-src-all@freebsd.org Fri Oct 28 16:27:59 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 95612C24304; Fri, 28 Oct 2016 16:27:59 +0000 (UTC) (envelope-from gnn@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3BB2BDCA; Fri, 28 Oct 2016 16:27:59 +0000 (UTC) (envelope-from gnn@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9SGRwvN020200; Fri, 28 Oct 2016 16:27:58 GMT (envelope-from gnn@FreeBSD.org) Received: (from gnn@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9SGRwQY020199; Fri, 28 Oct 2016 16:27:58 GMT (envelope-from gnn@FreeBSD.org) Message-Id: <201610281627.u9SGRwQY020199@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gnn set sender to gnn@FreeBSD.org using -f From: "George V. Neville-Neil" Date: Fri, 28 Oct 2016 16:27:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r308053 - stable/11/cddl/contrib/opensolaris/lib/libdtrace/common X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Oct 2016 16:27:59 -0000 Author: gnn Date: Fri Oct 28 16:27:58 2016 New Revision: 308053 URL: https://svnweb.freebsd.org/changeset/base/308053 Log: Corrected non-portable reuse of va_list in dt_printf() Submitted by: Graeme Jenkinson Reviewed by: markj Modified: stable/11/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c Directory Properties: stable/11/ (props changed) Modified: stable/11/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c Fri Oct 28 16:22:45 2016 (r308052) +++ stable/11/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c Fri Oct 28 16:27:58 2016 (r308053) @@ -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, c 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, c 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, c 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, c 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) {