diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2001-07-25 15:18:15 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2001-07-25 15:18:15 +0000 |
commit | 6795b173e3850ea6742e192b55655a4ba3677b2c (patch) | |
tree | f50788e5ae458f800b6fff95ea7083df1f50a49d /sbin/isakmpd | |
parent | 8a9a821cdac41de2d9a03368fd682a37b552a59d (diff) |
CFG mode changes: send attributes of size 0 if attribute is not available
fix several if statements, ok ho@
Diffstat (limited to 'sbin/isakmpd')
-rw-r--r-- | sbin/isakmpd/isakmp_cfg.c | 64 |
1 files changed, 41 insertions, 23 deletions
diff --git a/sbin/isakmpd/isakmp_cfg.c b/sbin/isakmpd/isakmp_cfg.c index 1e652405301..f4600187c83 100644 --- a/sbin/isakmpd/isakmp_cfg.c +++ b/sbin/isakmpd/isakmp_cfg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: isakmp_cfg.c,v 1.3 2001/07/04 07:41:19 niklas Exp $ */ +/* $OpenBSD: isakmp_cfg.c,v 1.4 2001/07/25 15:18:14 markus Exp $ */ /* * Copyright (c) 2001 Niklas Hallqvist. All rights reserved. @@ -331,10 +331,10 @@ responder_send_ATTR (struct message *msg) attrlen += ISAKMP_ATTR_SZ + attr->length; } - attrp = malloc (attrlen); + attrp = calloc (1, attrlen); if (!attrp) { - log_error ("responder_send_ATTR: malloc (%d) failed", attrlen); + log_error ("responder_send_ATTR: calloc (1, %d) failed", attrlen); return -1; } @@ -352,7 +352,6 @@ responder_send_ATTR (struct message *msg) off += ISAKMP_ATTR_SZ + attr->length, attr = LIST_NEXT (attr, link)) { SET_ISAKMP_ATTR_TYPE (attrp + off, attr->type); - SET_ISAKMP_ATTR_LENGTH_VALUE (attrp + off, attr->length); switch (attr->type) { case ISAKMP_CFG_ATTR_INTERNAL_IP4_ADDRESS: @@ -360,15 +359,21 @@ responder_send_ATTR (struct message *msg) /* XXX The section should be tagged off the peer somehow. */ sa = conf_get_address ("ISAKMP-cfg", "Address"); if (!sa) - /* XXX What to do? */ - continue; + { + /* XXX What to do? */ + attr->length = 0; + break; + } if ((attr->type == ISAKMP_CFG_ATTR_INTERNAL_IP4_ADDRESS && sa->sa_family != AF_INET) || (attr->type == ISAKMP_CFG_ATTR_INTERNAL_IP6_ADDRESS && sa->sa_family != AF_INET6)) - /* XXX What to do? */ - free (sa); - continue; + { + /* XXX What to do? */ + free (sa); + attr->length = 0; + break; + } memcpy (attrp + off + ISAKMP_ATTR_VALUE_OFF, sockaddr_data (sa), attr->length); @@ -392,15 +397,21 @@ responder_send_ATTR (struct message *msg) /* XXX The section should be tagged off the peer somehow. */ sa = conf_get_address ("ISAKMP-cfg", "Nameserver"); if (!sa) - /* XXX What to do? */ - continue; - if ((attr->type == ISAKMP_CFG_ATTR_INTERNAL_IP4_ADDRESS + { + /* XXX What to do? */ + attr->length = 0; + break; + } + if ((attr->type == ISAKMP_CFG_ATTR_INTERNAL_IP4_DNS && sa->sa_family != AF_INET) - || (attr->type == ISAKMP_CFG_ATTR_INTERNAL_IP6_ADDRESS + || (attr->type == ISAKMP_CFG_ATTR_INTERNAL_IP6_DNS && sa->sa_family != AF_INET6)) - /* XXX What to do? */ - free (sa); - continue; + { + /* XXX What to do? */ + attr->length = 0; + free (sa); + break; + } memcpy (attrp + off + ISAKMP_ATTR_VALUE_OFF, sockaddr_data (sa), attr->length); @@ -412,15 +423,21 @@ responder_send_ATTR (struct message *msg) /* XXX The section should be tagged off the peer somehow. */ sa = conf_get_address ("ISAKMP-cfg", "WINS-server"); if (!sa) - /* XXX What to do? */ - continue; - if ((attr->type == ISAKMP_CFG_ATTR_INTERNAL_IP4_ADDRESS + { + /* XXX What to do? */ + attr->length = 0; + break; + } + if ((attr->type == ISAKMP_CFG_ATTR_INTERNAL_IP4_NBNS && sa->sa_family != AF_INET) - || (attr->type == ISAKMP_CFG_ATTR_INTERNAL_IP6_ADDRESS + || (attr->type == ISAKMP_CFG_ATTR_INTERNAL_IP6_NBNS && sa->sa_family != AF_INET6)) - /* XXX What to do? */ - free (sa); - continue; + { + /* XXX What to do? */ + attr->length = 0; + free (sa); + break; + } memcpy (attrp + off + ISAKMP_ATTR_VALUE_OFF, sockaddr_data (sa), attr->length); @@ -442,6 +459,7 @@ responder_send_ATTR (struct message *msg) default: } + SET_ISAKMP_ATTR_LENGTH_VALUE (attrp + off, attr->length); } if (exchange->phase == 2) |