Index: sbin/isakmpd/message.c
===================================================================
RCS file: /cvs/src/sbin/isakmpd/message.c,v
retrieving revision 1.61.2.2
retrieving revision 1.61.2.4
diff -u -p -r1.61.2.2 -r1.61.2.4
--- sbin/isakmpd/message.c 17 Mar 2004 14:59:18 -0000 1.61.2.2
+++ sbin/isakmpd/message.c 11 Jun 2004 03:08:02 -0000 1.61.2.4
@@ -458,6 +458,11 @@ message_validate_cert_req (struct messag
/*
* Validate the delete payload P in message MSG. As a side-effect, create
* an exchange if we do not have one already.
+ *
+ * Note: DELETEs are only accepted as part of an INFORMATIONAL exchange.
+ * exchange_validate() makes sure a HASH payload is present. Due to the order
+ * of message validation functions in message_validate_payload[] we can be
+ * sure that the HASH payload has been successfully validated at this point.
*/
static int
message_validate_delete (struct message *msg, struct payload *p)
@@ -471,6 +476,13 @@ message_validate_delete (struct message
int i;
char *addr;
+ /* Only accpet authenticated DELETEs. */
+ if ((msg->flags & MSG_AUTHENTICATED) == 0)
+ {
+ log_print("message_validate_delete: got unauthenticated DELETE");
+ return -1;
+ }
+
doi = doi_lookup (GET_ISAKMP_DELETE_DOI (p->p));
if (!doi)
{
@@ -494,7 +506,14 @@ message_validate_delete (struct message
return -1;
}
}
-
+ /* Only accept DELETE as part of an INFORMATIONAL exchange. */
+ if (msg->exchange->type != ISAKMP_EXCH_INFO) {
+ log_print("message_validate_delete: delete in exchange other "
+ "than INFO: %s", constant_name(isakmp_exch_cst,
+ msg->exchange->type));
+ message_free(msg);
+ return -1;
+ }
if (proto != ISAKMP_PROTO_ISAKMP && doi->validate_proto (proto))
{
log_print ("message_validate_delete: protocol not supported");
@@ -567,9 +586,10 @@ message_validate_hash (struct message *m
u_int8_t message_id[ISAKMP_HDR_MESSAGE_ID_LEN];
size_t rest_len;
- if (msg->exchange) /* active exchange validates hash payload. */
+ /* active exchanges other than INFORMATIONAL validates hash payload. */
+ if (msg->exchange && (msg->exchange->type != ISAKMP_EXCH_INFO))
return 0;
-
+
if (isakmp_sa == NULL)
{
log_print ("message_validate_hash: invalid hash information");
@@ -644,6 +664,9 @@ message_validate_hash (struct message *m
/* Mark the HASH as handled. */
hashp->flags |= PL_MARK;
+
+ /* Mark message as authenticated. */
+ msg->flags |= MSG_AUTHENTICATED;
/* This message should be kept on the prioritized sendq. */
#define MSG_PRIORITIZED 8
+
+/* This message has successfully been authenticated. */
+#define MSG_AUTHENTICATED 16