Subject: memleak fix for lib/libipsec/pfkey.c
To: security <tech-security@netbsd.org>
From: Patrick Latifi <patrickl@secureops.com>
List: tech-security
Date: 03/04/2003 11:06:49
correct me if i'm wrong, but this could lead to a leak if we loop
more than once.
--- pfkey.c.orig Tue Mar 4 11:00:54 2003
+++ pfkey.c Tue Mar 4 11:02:15 2003
@@ -706,8 +706,12 @@
do {
if ((newmsg = pfkey_recv(so)) == NULL)
return -1;
- } while (newmsg->sadb_msg_type != SADB_REGISTER
- || newmsg->sadb_msg_pid != pid);
+ if (newmsg->sadb_msg_type != SADB_REGISTER ||
+ newmsg->sadb_msg_pid != pid)
+ free(newmsg);
+ else
+ break;
+ } while (1);
/* check and fix */
newmsg->sadb_msg_len = PFKEY_UNUNIT64(newmsg->sadb_msg_len);