summaryrefslogtreecommitdiff
path: root/sbin/isakmpd/pf_key_v2.c
diff options
context:
space:
mode:
authorAngelos D. Keromytis <angelos@cvs.openbsd.org>2001-07-01 18:27:38 +0000
committerAngelos D. Keromytis <angelos@cvs.openbsd.org>2001-07-01 18:27:38 +0000
commitf27953192afc9b5a3e6242306bc5a8d913004d94 (patch)
treed83778df751300f28e3347eab2bb7e4a7cb3ac01 /sbin/isakmpd/pf_key_v2.c
parent0834bde8262d89fe0a1b8f247c760c2ef2ee40fe (diff)
Return the right length for address IDs.
Diffstat (limited to 'sbin/isakmpd/pf_key_v2.c')
-rw-r--r--sbin/isakmpd/pf_key_v2.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/sbin/isakmpd/pf_key_v2.c b/sbin/isakmpd/pf_key_v2.c
index 5f1dc88192e..a3fc2523fb5 100644
--- a/sbin/isakmpd/pf_key_v2.c
+++ b/sbin/isakmpd/pf_key_v2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf_key_v2.c,v 1.73 2001/07/01 05:16:03 angelos Exp $ */
+/* $OpenBSD: pf_key_v2.c,v 1.74 2001/07/01 18:27:37 angelos Exp $ */
/* $EOM: pf_key_v2.c,v 1.79 2000/12/12 00:33:19 niklas Exp $ */
/*
@@ -1997,8 +1997,9 @@ pf_key_v2_convert_id (u_int8_t *id, int idlen, int *reslen, int *idtype)
case IPSEC_ID_IPV4_ADDR: /* XXX CONNECTION ? */
if (inet_ntop (AF_INET, id + ISAKMP_ID_DATA_OFF - ISAKMP_GEN_SZ,
- addrbuf, ADDRESS_MAX) != NULL)
- *reslen = strlen (addrbuf) + 4;
+ addrbuf, ADDRESS_MAX) == NULL)
+ return 0;
+ *reslen = strlen (addrbuf) + 3;
strcat (addrbuf, "/32");
res = strdup (addrbuf);
if (!res)
@@ -2008,8 +2009,9 @@ pf_key_v2_convert_id (u_int8_t *id, int idlen, int *reslen, int *idtype)
case IPSEC_ID_IPV6_ADDR: /* XXX CONNECTION ? */
if (inet_ntop (AF_INET6, id + ISAKMP_ID_DATA_OFF - ISAKMP_GEN_SZ,
- addrbuf, ADDRESS_MAX) != NULL)
- *reslen = strlen (addrbuf) + 5;
+ addrbuf, ADDRESS_MAX) == NULL)
+ return 0;
+ *reslen = strlen (addrbuf) + 4;
strcat (addrbuf, "/128");
res = strdup (addrbuf);
if (!res)
@@ -2019,11 +2021,12 @@ pf_key_v2_convert_id (u_int8_t *id, int idlen, int *reslen, int *idtype)
case IPSEC_ID_IPV4_ADDR_SUBNET: /* XXX PREFIX */
addr = id + ISAKMP_ID_DATA_OFF - ISAKMP_GEN_SZ;
- if (inet_ntop (AF_INET, addr, addrbuf, ADDRESS_MAX) != NULL)
- *reslen = strlen (addrbuf) + 4;
+ if (inet_ntop (AF_INET, addr, addrbuf, ADDRESS_MAX) == NULL)
+ return 0;
sprintf (addrbuf + strlen (addrbuf), "/%d",
pf_key_v2_mask_to_bits ((u_int32_t)*(addr +
sizeof (struct in_addr))));
+ *reslen = strlen(addrbuf);
res = strdup (addrbuf);
if (!res)
return 0;
@@ -2032,10 +2035,11 @@ pf_key_v2_convert_id (u_int8_t *id, int idlen, int *reslen, int *idtype)
case IPSEC_ID_IPV6_ADDR_SUBNET: /* XXX PREFIX */
addr = id + ISAKMP_ID_DATA_OFF - ISAKMP_GEN_SZ;
- if (inet_ntop (AF_INET6, addr, addrbuf, ADDRESS_MAX) != NULL)
- *reslen = strlen (addrbuf) + 5;
+ if (inet_ntop (AF_INET6, addr, addrbuf, ADDRESS_MAX) == NULL)
+ return 0;
sprintf (addrbuf + strlen (addrbuf), "/%d",
pf_key_v2_mask6_to_bits (addr + sizeof (struct in6_addr)));
+ *reslen = strlen (addrbuf);
res = strdup (addrbuf);
if (!res)
return 0;