Subject: Re: memleak fix for lib/libipsec/pfkey.c
To: None <tech-security@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: tech-security
Date: 03/04/2003 18:30:13
In article <20030304160649.GB14774@seymour>,
Patrick Latifi <patrickl@secureops.com> wrote:
You are correct.
christos
>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);