Module Name: src Committed By: matt Date: Wed Jun 6 05:10:54 UTC 2012
Modified Files: src/sys/kern: kern_sysctl.c Log Message: Make sure va_end is used even when errors are encountered. To generate a diff of this commit: cvs rdiff -u -r1.235 -r1.236 src/sys/kern/kern_sysctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/kern_sysctl.c diff -u src/sys/kern/kern_sysctl.c:1.235 src/sys/kern/kern_sysctl.c:1.236 --- src/sys/kern/kern_sysctl.c:1.235 Sat Jun 2 21:36:46 2012 +++ src/sys/kern/kern_sysctl.c Wed Jun 6 05:10:54 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_sysctl.c,v 1.235 2012/06/02 21:36:46 dsl Exp $ */ +/* $NetBSD: kern_sysctl.c,v 1.236 2012/06/06 05:10:54 matt Exp $ */ /*- * Copyright (c) 2003, 2007, 2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.235 2012/06/02 21:36:46 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.236 2012/06/06 05:10:54 matt Exp $"); #include "opt_defcorename.h" #include "ksyms.h" @@ -1957,19 +1957,26 @@ sysctl_createv(struct sysctllog **log, i */ va_start(ap, newlen); namelen = 0; + error = 0; ni = -1; do { - if (++ni == CTL_MAXNAME) - return (ENAMETOOLONG); + if (++ni == CTL_MAXNAME) { + error = ENAMETOOLONG; + break; + } name[ni] = va_arg(ap, int); /* * sorry, this is not supported from here */ - if (name[ni] == CTL_CREATESYM) - return (EINVAL); + if (name[ni] == CTL_CREATESYM) { + error = EINVAL; + break; + } } while (name[ni] != CTL_EOL && name[ni] != CTL_CREATE); - namelen = ni + (name[ni] == CTL_CREATE ? 1 : 0); va_end(ap); + if (error) + return error; + namelen = ni + (name[ni] == CTL_CREATE ? 1 : 0); /* * what's it called