Commit 9d8d4f48 authored by Youness Alaoui's avatar Youness Alaoui

use g_strlcpy instead of strncpy and memcpy for the candidate foundation,...

use g_strlcpy instead of strncpy and memcpy for the candidate foundation, because it makes sure we have a trailing null char in our string.
parent fc04f37a
......@@ -1574,7 +1574,8 @@ static gboolean priv_add_remote_candidate (
candidate->base_addr = *base_addr;
candidate->priority = priority;
if (foundation)
strncpy(candidate->foundation, foundation, NICE_CANDIDATE_MAX_FOUNDATION);
g_strlcpy(candidate->foundation, foundation,
NICE_CANDIDATE_MAX_FOUNDATION);
/* note: username and password must remain the same during
* a session; see sect 9.1.2 in ICE ID-19 */
......@@ -1620,17 +1621,18 @@ static gboolean priv_add_remote_candidate (
addr? nice_address_get_port (addr) : 0, stream_id, component_id,
username, password, priority);
}
if (base_addr)
candidate->base_addr = *base_addr;
candidate->transport = transport;
candidate->priority = priority;
candidate->username = g_strdup (username);
candidate->password = g_strdup (password);
if (foundation)
g_strlcpy (candidate->foundation, foundation, NICE_CANDIDATE_MAX_FOUNDATION);
g_strlcpy (candidate->foundation, foundation,
NICE_CANDIDATE_MAX_FOUNDATION);
if (conn_check_add_for_candidate (agent, stream_id, component, candidate) < 0)
error_flag = TRUE;
......
......@@ -330,7 +330,8 @@ static void priv_assign_foundation (NiceAgent *agent, NiceCandidate *candidate)
* time is supported, so there is no need to check
* for candidates that would otherwise share the
* foundation, but have different STUN/TURN servers */
memcpy (candidate->foundation, n->foundation, NICE_CANDIDATE_MAX_FOUNDATION);
g_strlcpy (candidate->foundation, n->foundation,
NICE_CANDIDATE_MAX_FOUNDATION);
if (n->username) {
g_free (candidate->username);
candidate->username = g_strdup (n->username);
......@@ -345,7 +346,8 @@ static void priv_assign_foundation (NiceAgent *agent, NiceCandidate *candidate)
}
}
g_snprintf (candidate->foundation, NICE_CANDIDATE_MAX_FOUNDATION, "%u", agent->next_candidate_id++);
g_snprintf (candidate->foundation, NICE_CANDIDATE_MAX_FOUNDATION,
"%u", agent->next_candidate_id++);
}
static void priv_assign_remote_foundation (NiceAgent *agent, NiceCandidate *candidate)
......@@ -380,7 +382,8 @@ static void priv_assign_remote_foundation (NiceAgent *agent, NiceCandidate *cand
* time is supported, so there is no need to check
* for candidates that would otherwise share the
* foundation, but have different STUN/TURN servers */
memcpy (candidate->foundation, n->foundation, NICE_CANDIDATE_MAX_FOUNDATION);
g_strlcpy (candidate->foundation, n->foundation,
NICE_CANDIDATE_MAX_FOUNDATION);
if (n->username) {
g_free (candidate->username);
candidate->username = g_strdup (n->username);
......
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