Commit 829ac1ae authored by Youness Alaoui's avatar Youness Alaoui

Avoid segfaulting if no message integrity attribute is found. Also make sure...

Avoid segfaulting if no message integrity attribute is found. Also make sure that if it happens, it's only accepted on error responses with codes bad-request and unauthorized.
parent 54406292
......@@ -210,6 +210,7 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg,
hash = (uint8_t *) stun_message_find (msg,
STUN_ATTRIBUTE_MESSAGE_INTEGRITY, &hlen);
if (hash) {
/* We must give the size from start to the end of the attribute
because you might have a FINGERPRINT attribute after it... */
stun_sha1 (msg->buffer, hash + 20 - msg->buffer, sha, key, key_len);
......@@ -230,6 +231,12 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg,
stun_debug ("STUN auth: OK!\n");
msg->key = key;
msg->key_len = key_len;
} else if (!(stun_message_get_class (msg) == STUN_ERROR &&
stun_message_find_error (msg, &error_code) == 0 &&
(error_code == 400 || error_code == 401))) {
stun_debug ("STUN auth error: No message integrity attribute!\n");
return STUN_VALIDATION_UNAUTHORIZED;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment