Commit e60ef6a5 authored by Youness Alaoui's avatar Youness Alaoui

Should fix key checking for gtalk compat

parent fb73b847
......@@ -1058,7 +1058,7 @@ int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair)
&sockaddr, sizeof (sockaddr),
uname, password,
cand_use, controlling, priority,
agent->tie_breaker);
agent->tie_breaker, agent->compatibility);
timeout = stun_bind_timeout (pair->stun_ctx);
/* note: convert from milli to microseconds for g_time_val_add() */
......
......@@ -201,8 +201,8 @@ int main (void)
nice_udp_bsd_socket_factory_init (&udpfactory);
/* step: create the agents L and R */
lagent = nice_agent_new (&udpfactory, lmainctx, NICE_COMPATIBILITY_ID19);
ragent = nice_agent_new (&udpfactory, rmainctx, NICE_COMPATIBILITY_ID19);
lagent = nice_agent_new (&udpfactory, lmainctx, NICE_COMPATIBILITY_GOOGLE);
ragent = nice_agent_new (&udpfactory, rmainctx, NICE_COMPATIBILITY_GOOGLE);
g_object_set_data (G_OBJECT (lagent), "other-agent", ragent);
g_object_set_data (G_OBJECT (ragent), "other-agent", lagent);
......
......@@ -262,7 +262,7 @@ stun_conncheck_start (stun_bind_t **restrict context, int fd,
const struct sockaddr *restrict srv, socklen_t srvlen,
const char *username, const char *password,
bool cand_use, bool controlling, uint32_t priority,
uint64_t tie)
uint64_t tie, uint32_t compat)
{
int val;
stun_bind_t *ctx;
......@@ -275,15 +275,17 @@ stun_conncheck_start (stun_bind_t **restrict context, int fd,
return val;
ctx = *context;
ctx->trans.key.length = strlen (password);
ctx->trans.key.value = malloc (ctx->trans.key.length);
if (ctx->trans.key.value == NULL)
{
val = ENOMEM;
goto error;
}
if (compat != 1) {
ctx->trans.key.length = strlen (password);
ctx->trans.key.value = malloc (ctx->trans.key.length);
if (ctx->trans.key.value == NULL)
{
val = ENOMEM;
goto error;
}
memcpy (ctx->trans.key.value, password, ctx->trans.key.length);
memcpy (ctx->trans.key.value, password, ctx->trans.key.length);
}
if (cand_use)
{
......
......@@ -71,7 +71,7 @@ int stun_conncheck_start (stun_bind_t **restrict context, int fd,
const struct sockaddr *restrict srv, socklen_t srvlen,
const char *username, const char *password,
bool cand_use, bool controlling, uint32_t priority,
uint64_t tie);
uint64_t tie, uint32_t compat);
/**
* Tries to parse a STUN connectivity check (Binding request) and format a
......
......@@ -119,10 +119,12 @@ stun_conncheck_reply (uint8_t *restrict buf, size_t *restrict plen,
return EPROTO;
}
DBG ("compat = %d - username %d - pass %d\n", compat, stun_present (msg, STUN_USERNAME), stun_present (msg, STUN_MESSAGE_INTEGRITY));
/* Short term credentials checking */
val = 0;
if (!stun_present (msg, STUN_MESSAGE_INTEGRITY)
|| (compat != 1 && !stun_present (msg, STUN_USERNAME)))
if (!stun_present (msg, STUN_USERNAME)
|| (compat != 1 && !stun_present (msg, STUN_MESSAGE_INTEGRITY)))
{
DBG (" Missing USERNAME or MESSAGE-INTEGRITY.\n");
val = STUN_BAD_REQUEST;
......
......@@ -71,7 +71,7 @@ int stun_conncheck_start (stun_bind_t **restrict context, int fd,
const struct sockaddr *restrict srv, socklen_t srvlen,
const char *username, const char *password,
bool cand_use, bool controlling, uint32_t priority,
uint64_t tie);
uint64_t tie, uint32_t compat);
/**
* Tries to parse a STUN connectivity check (Binding request) and format a
......
......@@ -601,12 +601,12 @@ stun_match_answer (const uint8_t *msg, stun_method_t method,
* currently ignore them. */
if (stun_verify_key (msg, key, keylen) != 0)
return false;
}
}/*
else
{
if (stun_present (msg, STUN_MESSAGE_INTEGRITY))
return false;
}
}*/
return true;
}
......
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