summaryrefslogtreecommitdiff
path: root/sbin/ipsecctl/pfkey.c
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2006-06-01 12:20:00 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2006-06-01 12:20:00 +0000
commit7acba1e80465cf8a211886130942b49523343441 (patch)
tree5e6d8b5a82ac2bc79c22ca2045baf667323b3be5 /sbin/ipsecctl/pfkey.c
parent633038fac5a0318e13aa2e76aed8a6ee1f7a7cb7 (diff)
read the full reply from PFKEY even if sadb_errno is set; ok hshoexer
Diffstat (limited to 'sbin/ipsecctl/pfkey.c')
-rw-r--r--sbin/ipsecctl/pfkey.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/sbin/ipsecctl/pfkey.c b/sbin/ipsecctl/pfkey.c
index 2288515c101..3e70713b389 100644
--- a/sbin/ipsecctl/pfkey.c
+++ b/sbin/ipsecctl/pfkey.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfkey.c,v 1.41 2006/06/01 06:20:30 todd Exp $ */
+/* $OpenBSD: pfkey.c,v 1.42 2006/06/01 12:19:59 markus Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
* Copyright (c) 2003, 2004 Markus Friedl <markus@openbsd.org>
@@ -608,11 +608,6 @@ pfkey_reply(int sd, u_int8_t **datap, ssize_t *lenp)
warnx("short read");
return -1;
}
- if (datap == NULL && hdr.sadb_msg_errno != 0) {
- errno = hdr.sadb_msg_errno;
- warn("PF_KEY failed");
- return -1;
- }
len = hdr.sadb_msg_len * PFKEYV2_CHUNK;
if ((data = malloc(len)) == NULL)
err(1, "pfkey_reply: malloc");
@@ -630,7 +625,11 @@ pfkey_reply(int sd, u_int8_t **datap, ssize_t *lenp)
bzero(data, len);
free(data);
}
-
+ if (datap == NULL && hdr.sadb_msg_errno != 0) {
+ errno = hdr.sadb_msg_errno;
+ warn("PF_KEY failed");
+ return -1;
+ }
return 0;
}