diff options
author | Hans-Joerg Hoexer <hshoexer@cvs.openbsd.org> | 2005-08-03 15:27:02 +0000 |
---|---|---|
committer | Hans-Joerg Hoexer <hshoexer@cvs.openbsd.org> | 2005-08-03 15:27:02 +0000 |
commit | aa4731269e4cee4ca61f860c2d14c46fa59b99c4 (patch) | |
tree | 754fe14c6aefc2a678b45a171d0c91b5f1f30a93 /sbin | |
parent | 6c5f8ba04aeb711d3131889a5732791882ae2eed (diff) |
be more careful when using struct ipsec_auth, might be NULL now.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/ipsecctl/ipsecctl.c | 16 | ||||
-rw-r--r-- | sbin/ipsecctl/pfkey.c | 16 |
2 files changed, 24 insertions, 8 deletions
diff --git a/sbin/ipsecctl/ipsecctl.c b/sbin/ipsecctl/ipsecctl.c index 60a95ab861f..0dff2042a45 100644 --- a/sbin/ipsecctl/ipsecctl.c +++ b/sbin/ipsecctl/ipsecctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ipsecctl.c,v 1.20 2005/08/02 15:47:25 hshoexer Exp $ */ +/* $OpenBSD: ipsecctl.c,v 1.21 2005/08/03 15:27:01 hshoexer Exp $ */ /* * Copyright (c) 2004, 2005 Hans-Joerg Hoexer <hshoexer@openbsd.org> * @@ -226,12 +226,14 @@ ipsecctl_print_flow(struct ipsec_rule *r, int opts) ipsecctl_print_addr(r->peer); if (opts & IPSECCTL_OPT_VERBOSE) { - if (r->auth->srcid) - printf("\n\tsrcid %s", r->auth->srcid); - if (r->auth->dstid) - printf("\n\tdstid %s", r->auth->dstid); - if (r->auth->type > 0) - printf("\n\t%s", auth[r->auth->type]); + if (r->auth) { + if (r->auth->srcid) + printf("\n\tsrcid %s", r->auth->srcid); + if (r->auth->dstid) + printf("\n\tdstid %s", r->auth->dstid); + if (r->auth->type > 0) + printf("\n\t%s", auth[r->auth->type]); + } printf("\n\ttype %s", flowtype[r->flowtype]); } } diff --git a/sbin/ipsecctl/pfkey.c b/sbin/ipsecctl/pfkey.c index 4b2a7ac6d5f..de1f08e5f14 100644 --- a/sbin/ipsecctl/pfkey.c +++ b/sbin/ipsecctl/pfkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfkey.c,v 1.17 2005/08/02 15:47:25 hshoexer Exp $ */ +/* $OpenBSD: pfkey.c,v 1.18 2005/08/03 15:27:01 hshoexer Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004 Markus Friedl <markus@openbsd.org> @@ -537,6 +537,13 @@ pfkey_parse(struct sadb_msg *msg, struct ipsec_rule *rule) len = (sident->sadb_ident_len * sizeof(uint64_t)) - sizeof(struct sadb_ident); + if (rule->auth == NULL) { + rule->auth = calloc(1, sizeof(struct + ipsec_auth)); + if (rule->auth == NULL) + err(1, "calloc"); + } + rule->auth->srcid = calloc(1, len); if (rule->auth->srcid == NULL) err(1, "calloc"); @@ -549,6 +556,13 @@ pfkey_parse(struct sadb_msg *msg, struct ipsec_rule *rule) len = (sident->sadb_ident_len * sizeof(uint64_t)) - sizeof(struct sadb_ident); + if (rule->auth == NULL) { + rule->auth = calloc(1, sizeof(struct + ipsec_auth)); + if (rule->auth == NULL) + err(1, "calloc"); + } + rule->auth->dstid = calloc(1, len); if (rule->auth->dstid == NULL) err(1, "calloc"); |