diff options
author | ume <ume@FreeBSD.org> | 2003-11-05 09:41:23 +0000 |
---|---|---|
committer | ume <ume@FreeBSD.org> | 2003-11-05 09:41:23 +0000 |
commit | 1b0d2b237ef5dc12f3fb211efc7b75ca8569ceea (patch) | |
tree | 1ea09163a35ae85d875bf32809246ad32e65bf53 /lib/libipsec/pfkey.c | |
parent | 0206145b43bc58420bb652c29f4f7a986f05117b (diff) | |
download | FreeBSD-src-1b0d2b237ef5dc12f3fb211efc7b75ca8569ceea.zip FreeBSD-src-1b0d2b237ef5dc12f3fb211efc7b75ca8569ceea.tar.gz |
- plug memory leak.
- fixed a length of the sadb extension in the case of pfkey_send_x5().
- used getprotobynumber() for printing a upper layer protocol name.
- modified the output format against the change of the setkey syntax
about a icmp6 type/code.
- don't enumerate reserved fields. use memset.
Obtained from: KAME
Diffstat (limited to 'lib/libipsec/pfkey.c')
-rw-r--r-- | lib/libipsec/pfkey.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/libipsec/pfkey.c b/lib/libipsec/pfkey.c index 42137f9..d7263ee 100644 --- a/lib/libipsec/pfkey.c +++ b/lib/libipsec/pfkey.c @@ -1,4 +1,4 @@ -/* $KAME: pfkey.c,v 1.39 2001/03/05 18:22:17 thorpej Exp $ */ +/* $KAME: pfkey.c,v 1.46 2003/08/26 03:37:06 itojun Exp $ */ /* * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project. @@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$"); #include <unistd.h> #include <string.h> #include <errno.h> -#include <stdio.h> #include "ipsec_strerror.h" #include "libpfkey.h" @@ -706,11 +705,14 @@ pfkey_recv_register(so) int error = -1; /* receive message */ - do { + for (;;) { 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) + break; + free(newmsg); + } /* check and fix */ newmsg->sadb_msg_len = PFKEY_UNUNIT64(newmsg->sadb_msg_len); @@ -1540,7 +1542,7 @@ pfkey_send_x5(so, type, spid) return -1; } memset(&xpl, 0, sizeof(xpl)); - xpl.sadb_x_policy_len = PFKEY_UNUNIT64(sizeof(xpl)); + xpl.sadb_x_policy_len = PFKEY_UNIT64(sizeof(xpl)); xpl.sadb_x_policy_exttype = SADB_X_EXT_POLICY; xpl.sadb_x_policy_id = spid; memcpy(p, &xpl, sizeof(xpl)); |