Commit cec76525 authored by Youness Alaoui's avatar Youness Alaoui

Correctly check for the username/password. Only check the start for our own...

Correctly check for the username/password. Only check the start for our own username and do not check for the semicolon. Also makes the code cleaner and fixes possible compat issue with msn for peer reflexive candidates
parent ad57e866
...@@ -1830,47 +1830,24 @@ static bool conncheck_stun_validater (StunAgent *agent, ...@@ -1830,47 +1830,24 @@ static bool conncheck_stun_validater (StunAgent *agent,
for (i = data->component->local_candidates; i; i = i->next) { for (i = data->component->local_candidates; i; i = i->next) {
NiceCandidate *cand = i->data; NiceCandidate *cand = i->data;
gchar *ufrag = NULL; gchar *ufrag = NULL;
gsize ufrag_len;
if (cand->username) if (cand->username)
ufrag = cand->username; ufrag = cand->username;
else if (data->stream) else if (data->stream)
ufrag = data->stream->local_ufrag; ufrag = data->stream->local_ufrag;
ufrag_len = strlen (ufrag);
if (data->agent->compatibility == NICE_COMPATIBILITY_ID19 && if (data->agent->compatibility == NICE_COMPATIBILITY_MSN)
strlen (ufrag) + 1 <= NICE_STREAM_MAX_UNAME) { ufrag = (gchar *)g_base64_decode (ufrag, &ufrag_len);
memcpy (uname, ufrag, strlen (ufrag));
uname_len = strlen (ufrag);
memcpy (uname + uname_len, ":", 1);
uname_len++;
} else if (data->agent->compatibility == NICE_COMPATIBILITY_GOOGLE &&
strlen (ufrag) <= NICE_STREAM_MAX_UNAME) {
memcpy (uname, ufrag, strlen (ufrag));
uname_len = strlen (ufrag);
} else if (data->agent->compatibility == NICE_COMPATIBILITY_MSN) {
gchar component_str[10];
guchar *local_decoded = NULL;
gsize local_decoded_len;
g_snprintf (component_str, sizeof(component_str),
"%d", data->component->id);
local_decoded = g_base64_decode (ufrag, &local_decoded_len);
if (local_decoded_len + 2 + strlen (component_str) <= if (ufrag_len <= NICE_STREAM_MAX_UNAME) {
NICE_STREAM_MAX_UNAME) { memcpy (uname, ufrag, ufrag_len);
uname_len = ufrag_len;
memcpy (uname, local_decoded, local_decoded_len);
uname_len = local_decoded_len;
memcpy (uname + uname_len, ":", 1);
uname_len++;
memcpy (uname + uname_len, component_str, strlen (component_str));
uname_len += strlen (component_str);
memcpy (uname + uname_len, ":", 1);
uname_len++;
} }
g_free (local_decoded); if (data->agent->compatibility == NICE_COMPATIBILITY_MSN)
} g_free (ufrag);
stun_debug ("Comparing username '"); stun_debug ("Comparing username '");
stun_debug_bytes (username, username_len); stun_debug_bytes (username, username_len);
......
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