Author: kevlo
Date: Tue May 29 01:48:06 2012
New Revision: 236213
URL: http://svn.freebsd.org/changeset/base/236213

Log:
  Make sure that each va_start has one and only one matching va_end,
  especially in error cases.

Modified:
  head/sbin/fsck_msdosfs/main.c
  head/sbin/restore/utilities.c
  head/sys/boot/i386/libi386/biospnp.c
  head/sys/compat/ndis/subr_ntoskrnl.c
  head/sys/i386/i386/bios.c
  head/usr.bin/chat/chat.c
  head/usr.sbin/pkg_install/lib/exec.c
  head/usr.sbin/pkg_install/lib/msg.c

Modified: head/sbin/fsck_msdosfs/main.c
==============================================================================
--- head/sbin/fsck_msdosfs/main.c       Tue May 29 00:53:51 2012        
(r236212)
+++ head/sbin/fsck_msdosfs/main.c       Tue May 29 01:48:06 2012        
(r236213)
@@ -138,6 +138,7 @@ ask(int def, const char *fmt, ...)
 
        va_start(ap, fmt);
        vsnprintf(prompt, sizeof(prompt), fmt, ap);
+       va_end(ap);
        if (alwaysyes || rdonly) {
                printf("%s? %s\n", prompt, rdonly ? "no" : "yes");
                return !rdonly;

Modified: head/sbin/restore/utilities.c
==============================================================================
--- head/sbin/restore/utilities.c       Tue May 29 00:53:51 2012        
(r236212)
+++ head/sbin/restore/utilities.c       Tue May 29 01:48:06 2012        
(r236213)
@@ -411,6 +411,7 @@ panic(const char *fmt, ...)
        va_list ap;
        va_start(ap, fmt);
        vfprintf(stderr, fmt, ap);
+       va_end(ap);
        if (yflag)
                return;
        if (reply("abort") == GOOD) {

Modified: head/sys/boot/i386/libi386/biospnp.c
==============================================================================
--- head/sys/boot/i386/libi386/biospnp.c        Tue May 29 00:53:51 2012        
(r236212)
+++ head/sys/boot/i386/libi386/biospnp.c        Tue May 29 01:48:06 2012        
(r236213)
@@ -276,6 +276,7 @@ biospnp_call(int func, const char *fmt, 
            break;
        }
     }
+    va_end(ap);
 
     /* BIOS segment last */
     *(u_int16_t *)argp = pnp_Icheck->pnp_rmds;

Modified: head/sys/compat/ndis/subr_ntoskrnl.c
==============================================================================
--- head/sys/compat/ndis/subr_ntoskrnl.c        Tue May 29 00:53:51 2012        
(r236212)
+++ head/sys/compat/ndis/subr_ntoskrnl.c        Tue May 29 01:48:06 2012        
(r236213)
@@ -3591,6 +3591,7 @@ DbgPrint(char *fmt, ...)
        if (bootverbose) {
                va_start(ap, fmt);
                vprintf(fmt, ap);
+               va_end(ap);
        }
 
        return (STATUS_SUCCESS);

Modified: head/sys/i386/i386/bios.c
==============================================================================
--- head/sys/i386/i386/bios.c   Tue May 29 00:53:51 2012        (r236212)
+++ head/sys/i386/i386/bios.c   Tue May 29 01:48:06 2012        (r236213)
@@ -372,9 +372,11 @@ bios16(struct bios_args *args, char *fmt
            break;
 
        default:
+           va_end(ap);
            return (EINVAL);
        }
     }
+    va_end(ap);
 
     if (flags & BIOSARGS_FLAG) {
        if (arg_end - arg_start > ctob(16))
@@ -448,9 +450,11 @@ bios16(struct bios_args *args, char *fmt
            break;
 
        default:
+           va_end(ap);
            return (EINVAL);
        }
     }
+    va_end(ap);
 
     set_bios_selectors(&args->seg, flags);
     bioscall_vector.vec16.offset = (u_short)args->entry;

Modified: head/usr.bin/chat/chat.c
==============================================================================
--- head/usr.bin/chat/chat.c    Tue May 29 00:53:51 2012        (r236212)
+++ head/usr.bin/chat/chat.c    Tue May 29 01:48:06 2012        (r236213)
@@ -408,6 +408,7 @@ chat_logf(const char *fmt, ...)
 
     va_start(args, fmt);
     vfmtmsg(line, sizeof(line), fmt, args);
+    va_end(args);
     if (to_log)
        syslog(LOG_INFO, "%s", line);
     if (to_stderr)
@@ -425,6 +426,7 @@ fatal(int code, const char *fmt, ...)
 
     va_start(args, fmt);
     vfmtmsg(line, sizeof(line), fmt, args);
+    va_end(args);
     if (to_log)
        syslog(LOG_ERR, "%s", line);
     if (to_stderr)

Modified: head/usr.sbin/pkg_install/lib/exec.c
==============================================================================
--- head/usr.sbin/pkg_install/lib/exec.c        Tue May 29 00:53:51 2012        
(r236212)
+++ head/usr.sbin/pkg_install/lib/exec.c        Tue May 29 01:48:06 2012        
(r236213)
@@ -47,6 +47,7 @@ vsystem(const char *fmt, ...)
     va_start(args, fmt);
     if (vsnprintf(cmd, maxargs, fmt, args) > maxargs) {
        warnx("vsystem args are too long");
+       va_end(args);
        return 1;
     }
 #ifdef DEBUG
@@ -82,6 +83,7 @@ vpipe(const char *fmt, ...)
     va_start(args, fmt);
     if (vsnprintf(cmd, maxargs, fmt, args) > maxargs) {
        warnx("vsystem args are too long");
+       va_end(args);
        return NULL;
     }
 #ifdef DEBUG

Modified: head/usr.sbin/pkg_install/lib/msg.c
==============================================================================
--- head/usr.sbin/pkg_install/lib/msg.c Tue May 29 00:53:51 2012        
(r236212)
+++ head/usr.sbin/pkg_install/lib/msg.c Tue May 29 01:48:06 2012        
(r236213)
@@ -71,5 +71,6 @@ y_or_n(Boolean def, const char *msg, ...
            ch = (def) ? 'Y' : 'N';
     }
     fclose(tty) ;
+    va_end(args);
     return (ch == 'Y') ? TRUE : FALSE;
 }
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to