Commit 1c7a8efd authored by Youness Alaoui's avatar Youness Alaoui

verify the username outside libstun only if we are in google compatibility mode

parent 0e0354b2
...@@ -1831,38 +1831,35 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream, ...@@ -1831,38 +1831,35 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
return TRUE; return TRUE;
} }
if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) {
/* If we receive a response, then the username is local:remote */ /* If we receive a response, then the username is local:remote */
if (stun_message_get_class (&req) == STUN_REQUEST || if (stun_message_get_class (&req) == STUN_REQUEST ||
stun_message_get_class (&req) == STUN_INDICATION) { stun_message_get_class (&req) == STUN_INDICATION) {
uname_len = priv_create_username (agent, stream, uname_len = priv_create_username (agent, stream,
component->id, remote_candidate, local_candidate, component->id, remote_candidate, local_candidate,
uname, sizeof (uname), TRUE); uname, sizeof (uname), TRUE);
} else { } else {
uname_len = priv_create_username (agent, stream, uname_len = priv_create_username (agent, stream,
component->id, remote_candidate, local_candidate, component->id, remote_candidate, local_candidate,
uname, sizeof (uname), FALSE); uname, sizeof (uname), FALSE);
} }
username = (uint8_t *) stun_message_find (&req, STUN_ATTRIBUTE_USERNAME,
&username_len);
username = (uint8_t *) stun_message_find (&req, STUN_ATTRIBUTE_USERNAME,
&username_len); /* Check the username in case the stun agent has IGNORE_CREDENTIALS flag.
We only need to check the username and not care about the password */
g_debug ("Comparing usernames : '%s' (%d) to '%s' (%d)", username, username_len, uname, uname_len); if (username &&
(uname_len != username_len ||
/* Check again the username in case the stun agent has IGNORE_CREDENTIALS flag. memcmp (uname, username, username_len) != 0)) {
We only need to check the username and not care about the password */ g_debug ("Agent %p : Username check failed.", agent);
if (username && if (stun_agent_init_error (&agent->stun_agent, &msg, rbuf, rbuf_len,
(uname_len != username_len || &req, STUN_ERROR_UNAUTHORIZED)) {
memcmp (uname, username, username_len) != 0)) { rbuf_len = stun_agent_finish_message (&agent->stun_agent, &msg, NULL, 0);
g_debug ("Agent %p : Username check failed.", agent); if (rbuf_len > 0&& agent->compatibility != NICE_COMPATIBILITY_MSN)
if (stun_agent_init_error (&agent->stun_agent, &msg, rbuf, rbuf_len, nice_udp_socket_send (udp_socket, from, rbuf_len, (const gchar*)rbuf);
&req, STUN_ERROR_UNAUTHORIZED)) { }
rbuf_len = stun_agent_finish_message (&agent->stun_agent, &msg, NULL, 0); return TRUE;
if (rbuf_len > 0)
nice_udp_socket_send (udp_socket, from, rbuf_len, (const gchar*)rbuf);
} }
return TRUE;
} }
if (valid != STUN_VALIDATION_SUCCESS) { if (valid != STUN_VALIDATION_SUCCESS) {
......
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