From d4db20087ce162e9ea5cb6c4662c2f4c1ac4d31f Mon Sep 17 00:00:00 2001 From: Bogdan-Andrei Iancu Date: Fri, 5 May 2023 10:21:17 +0300 Subject: [PATCH] [call_center] fix skill overflow on refreshing agents via MI Completes 6617ecc805520961642c16ac1e6c5a49787af2ab --- modules/call_center/cc_data.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/call_center/cc_data.c b/modules/call_center/cc_data.c index d729dd4fc57..223ca8f9185 100644 --- a/modules/call_center/cc_data.c +++ b/modules/call_center/cc_data.c @@ -683,6 +683,13 @@ int add_cc_agent( struct cc_data *data, str *id, struct media_info *media, if (skills && skills->len) { p = skills->s; while (p) { + if (agent->no_skills==MAX_SKILLS_PER_AGENT) { + LM_WARN("too many skills (%d) for the agent <%.*s>, " + "discarding <%.*s>\n", + agent->no_skills, agent->id.len, agent->id.s, + (int)(skills->s+skills->len-p), p); + break; + } skill.s = p; p = q_memchr(skill.s, ',', skills->s+skills->len-skill.s); skill.len = p?(p-skill.s):(skills->s+skills->len-skill.s); @@ -690,11 +697,13 @@ int add_cc_agent( struct cc_data *data, str *id, struct media_info *media, if (skill.len) { skill_id = get_skill_id(data,&skill); if (skill_id==0) { - LM_ERR("cannot get skill id\n"); - goto error1; + LM_WARN("unknown skill <%.*s> for the agent <%.*s>," + "discarding\n", + skill.len, skill.s, agent->id.len, agent->id.s); + } else { + n = agent->no_skills++; + agent->skills[n] = skill_id; } - n = agent->no_skills++; - agent->skills[n] = skill_id; } if(p) p++;