static int
-ipsec_validate_situation (u_int8_t *buf, size_t *sz)
+ipsec_validate_situation (u_int8_t *buf, size_t *sz, size_t len)
{
- int sit = GET_IPSEC_SIT_SIT (buf);
- int off;
-
- if (sit & (IPSEC_SIT_SECRECY | IPSEC_SIT_INTEGRITY))
- {
- /*
- * XXX All the roundups below, round up to 32 bit boundaries given
- * that the situation field is aligned. This is not necessarily so,
- * but I interpret the drafts as this is like this they want it.
- */
- off = ROUNDUP_32 (GET_IPSEC_SIT_SECRECY_LENGTH (buf));
- off += ROUNDUP_32 (GET_IPSEC_SIT_SECRECY_CAT_LENGTH (buf + off));
- off += ROUNDUP_32 (GET_IPSEC_SIT_INTEGRITY_LENGTH (buf + off));
- off += ROUNDUP_32 (GET_IPSEC_SIT_INTEGRITY_CAT_LENGTH (buf + off));
- *sz = off + IPSEC_SIT_SZ;
+ if (len < IPSEC_SIT_SIT_OFF + IPSEC_SIT_SIT_LEN)
+ {
+ log_print ("ipsec_validate_situation: payload too short: %u",
+ (unsigned int)len);
+ return -1;
}
- else
- *sz = IPSEC_SIT_SIT_LEN;
/* Currently only "identity only" situations are supported. */
-#ifdef notdef
- return
- sit & ~(IPSEC_SIT_IDENTITY_ONLY | IPSEC_SIT_SECRECY | IPSEC_SIT_INTEGRITY);
-#else
- return sit & ~IPSEC_SIT_IDENTITY_ONLY;
-#endif
+ if (GET_IPSEC_SIT_SIT (buf) != IPSEC_SIT_IDENTITY_ONLY)
return 1;
+
+ *sz = IPSEC_SIT_SIT_LEN;
+
return 0;
}
/* If no SKEYID_a, we can not do anything (should not happen). */
if (!isa->skeyid_a)
{
log_print ("message_validate_hash: invalid hash information");
+ message_drop (msg, ISAKMP_NOTIFY_INVALID_HASH_INFORMATION, 0, 1, 1);
return -1;
}
@@ -872,7 +901,8 @@ message_validate_sa (struct message *msg
* Let the DOI validate the situation, at the same time it tells us what
* the length of the situation field is.
*/
- if (exchange->doi->validate_situation (p->p + ISAKMP_SA_SIT_OFF, &len))
+ if (exchange->doi->validate_situation (p->p + ISAKMP_SA_SIT_OFF, &len,
+ GET_ISAKMP_GEN_LENGTH (p->p) - ISAKMP_SA_SIT_OFF))
{
log_print ("message_validate_sa: situation not supported");
message_drop (msg, ISAKMP_NOTIFY_SITUATION_NOT_SUPPORTED, 0, 1, 1);
@@ -1261,6 +1291,7 @@ message_recv (struct message *msg)
{
LOG_DBG ((LOG_MISC, 10,
"message_recv: no isakmp_sa for encrypted message"));
+ message_free (msg);
return -1;
}
@@ -1715,6 +1746,9 @@ message_drop (struct message *msg, int n
log_print ("dropped message from %s port %d due to notification type %s",
address ? address : "<unknown>", htons(port),
constant_name (isakmp_notify_cst, notify));
+
+ if (address)
+ free (address);
/* If specified, return a notification. */
if (notify)
Index: sbin/isakmpd/util.h
===================================================================
RCS file: /cvs/src/sbin/isakmpd/util.h,v
retrieving revision 1.14
retrieving revision 1.14.4.1
diff -u -p -r1.14 -r1.14.4.1
--- sbin/isakmpd/util.h 28 May 2002 11:23:20 -0000 1.14
+++ sbin/isakmpd/util.h 17 Mar 2004 15:05:03 -0000 1.14.4.1
@@ -39,8 +39,6 @@
#define _UTIL_H_