summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorHans-Joerg Hoexer <hshoexer@cvs.openbsd.org>2005-07-09 21:31:25 +0000
committerHans-Joerg Hoexer <hshoexer@cvs.openbsd.org>2005-07-09 21:31:25 +0000
commite7d1e0f02c282e076d71f80c57056ce2f0264f46 (patch)
treeec2841f363cd62c47e9e9b555fdd5c6293e6f606 /sbin
parentf15764e58170a530be9b46114425609374f1a87d (diff)
also bail out when pfkey returns ESRCH (eg. trying to delete a non-existing SA)
Diffstat (limited to 'sbin')
-rw-r--r--sbin/ipsecctl/pfkey.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/sbin/ipsecctl/pfkey.c b/sbin/ipsecctl/pfkey.c
index 1faca13301c..ce1aa93898c 100644
--- a/sbin/ipsecctl/pfkey.c
+++ b/sbin/ipsecctl/pfkey.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfkey.c,v 1.15 2005/07/09 21:17:46 hshoexer Exp $ */
+/* $OpenBSD: pfkey.c,v 1.16 2005/07/09 21:31:24 hshoexer Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
* Copyright (c) 2003, 2004 Markus Friedl <markus@openbsd.org>
@@ -363,6 +363,10 @@ pfkey_sa(int sd, u_int8_t satype, u_int8_t action, u_int32_t spi,
sa_dst.sadb_address_exttype = SADB_EXT_ADDRESS_DST;
if (action == SADB_ADD) {
+ if (!key) {
+ warnx("no key specified");
+ return -1;
+ }
bzero(&sa_key, sizeof(sa_key));
sa_key.sadb_key_len = (sizeof(sa_key) + ((key->len + 7) / 8)
* 8) / 8;
@@ -437,12 +441,8 @@ pfkey_reply(int sd)
}
if (hdr.sadb_msg_errno != 0) {
errno = hdr.sadb_msg_errno;
- if (errno == ESRCH)
- return 0;
- else {
- warn("PF_KEY returned error");
- return -1;
- }
+ warn("PF_KEY failed");
+ return -1;
}
len = hdr.sadb_msg_len * PFKEYV2_CHUNK;
if ((data = malloc(len)) == NULL)