Avoid crash in generic CC agent init if caller name or number is NULL.
authorRichard Mudgett <rmudgett@digium.com>
Thu, 20 May 2010 20:49:40 +0000 (20:49 +0000)
committerRichard Mudgett <rmudgett@digium.com>
Thu, 20 May 2010 20:49:40 +0000 (20:49 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@264711 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/ccss.c

index 8dd048c..04fa92a 100644 (file)
@@ -2339,8 +2339,12 @@ static int cc_generic_agent_init(struct ast_cc_agent *agent, struct ast_channel
        }
 
        generic_pvt->offer_timer_id = -1;
-       ast_copy_string(generic_pvt->cid_num, chan->cid.cid_num, sizeof(generic_pvt->cid_num));
-       ast_copy_string(generic_pvt->cid_name, chan->cid.cid_name, sizeof(generic_pvt->cid_name));
+       if (chan->cid.cid_num) {
+               ast_copy_string(generic_pvt->cid_num, chan->cid.cid_num, sizeof(generic_pvt->cid_num));
+       }
+       if (chan->cid.cid_name) {
+               ast_copy_string(generic_pvt->cid_name, chan->cid.cid_name, sizeof(generic_pvt->cid_name));
+       }
        ast_copy_string(generic_pvt->exten, S_OR(chan->macroexten, chan->exten), sizeof(generic_pvt->exten));
        ast_copy_string(generic_pvt->context, S_OR(chan->macrocontext, chan->context), sizeof(generic_pvt->context));
        agent->private_data = generic_pvt;