Merge netkey/key.c rev 1.51 (wiz):

va_{start,end} audit:
Make sure that each va_start has one and only one matching va_end,
especially in error cases.
If the va_list is used multiple times, do multiple va_starts/va_ends.
If a function gets va_list as argument, don't let it use va_end (since
it's the callers responsibility).

Improved by comments from enami and christos -- thanks!

Heimdal/krb4/KAME changes already fed back, rest to follow.

Inspired by, but not not based on, OpenBSD.
This commit is contained in:
thorpej 2004-03-01 18:33:03 +00:00
parent 293e83e97e
commit 31e39503c5

View File

@ -1,4 +1,4 @@
/* $NetBSD: key.c,v 1.7 2004/02/24 15:12:52 wiz Exp $ */
/* $NetBSD: key.c,v 1.8 2004/03/01 18:33:03 thorpej Exp $ */
/* $FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/netipsec/key.c,v 1.3.2.2 2003/07/01 01:38:13 sam Exp $ */
/* $KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $ */
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.7 2004/02/24 15:12:52 wiz Exp $");
__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.8 2004/03/01 18:33:03 thorpej Exp $");
/*
* This code is referd to RFC 2367
@ -1681,6 +1681,7 @@ key_gather_mbuf(m, mhp, ndeep, nitem, va_alist)
return result;
fail:
va_end(ap);
m_freem(result);
return NULL;
}