[svn-commits] trunk - r7872 /trunk/channels/chan_sip.c
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Mon Jan 9 00:42:29 CST 2006
Author: tilghman
Date: Mon Jan 9 00:42:28 2006
New Revision: 7872
URL: http://svn.digium.com/view/asterisk?rev=7872&view=rev
Log:
Bug 6150 - do not modify strings after they have been submitted into a string pool
Modified:
trunk/channels/chan_sip.c
Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=7872&r1=7871&r2=7872&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Mon Jan 9 00:42:28 2006
@@ -7060,11 +7060,17 @@
of += 4;
/* Get just the username part */
if ((c = strchr(of, '@'))) {
+ char *tmp;
*c = '\0';
if ((c = strchr(of, ':')))
*c = '\0';
- ast_string_field_set(p, cid_num, of);
- ast_shrink_phone_number((char *) p->cid_num);
+ tmp = ast_strdupa(of);
+ if (tmp) {
+ ast_shrink_phone_number(tmp);
+ ast_string_field_set(p, cid_num, tmp);
+ } else {
+ ast_string_field_set(p, cid_num, of);
+ }
}
if (ast_strlen_zero(of))
return 0;
@@ -7085,10 +7091,16 @@
p->prefs = user->prefs;
/* replace callerid if rpid found, and not restricted */
if (!ast_strlen_zero(rpid_num) && ast_test_flag(p, SIP_TRUSTRPID)) {
+ char *tmp;
if (*calleridname)
ast_string_field_set(p, cid_name, calleridname);
- ast_string_field_set(p, cid_num, rpid_num);
- ast_shrink_phone_number((char *) p->cid_num);
+ tmp = ast_strdupa(rpid_num);
+ if (tmp) {
+ ast_shrink_phone_number(tmp);
+ ast_string_field_set(p, cid_num, tmp);
+ } else {
+ ast_string_field_set(p, cid_num, rpid_num);
+ }
}
if (p->rtp) {
@@ -7114,8 +7126,13 @@
if (!ast_strlen_zero(user->context))
ast_string_field_set(p, context, user->context);
if (!ast_strlen_zero(user->cid_num) && !ast_strlen_zero(p->cid_num)) {
- ast_string_field_set(p, cid_num, user->cid_num);
- ast_shrink_phone_number((char *) p->cid_num);
+ char *tmp = ast_strdupa(user->cid_num);
+ if (tmp) {
+ ast_shrink_phone_number(tmp);
+ ast_string_field_set(p, cid_num, tmp);
+ } else {
+ ast_string_field_set(p, cid_num, user->cid_num);
+ }
}
if (!ast_strlen_zero(user->cid_name) && !ast_strlen_zero(p->cid_num))
ast_string_field_set(p, cid_name, user->cid_name);
@@ -7174,10 +7191,15 @@
/* replace callerid if rpid found, and not restricted */
if (!ast_strlen_zero(rpid_num) && ast_test_flag(p, SIP_TRUSTRPID)) {
+ char *tmp = ast_strdupa(rpid_num);
if (*calleridname)
ast_string_field_set(p, cid_name, calleridname);
- ast_string_field_set(p, cid_num, rpid_num);
- ast_shrink_phone_number((char *) p->cid_num);
+ if (tmp) {
+ ast_shrink_phone_number(tmp);
+ ast_string_field_set(p, cid_num, tmp);
+ } else {
+ ast_string_field_set(p, cid_num, rpid_num);
+ }
}
if (p->rtp) {
ast_log(LOG_DEBUG, "Setting NAT on RTP to %d\n", (ast_test_flag(p, SIP_NAT) & SIP_NAT_ROUTE));
@@ -7221,8 +7243,13 @@
ast_string_field_set(p, authname, peer->username);
}
if (!ast_strlen_zero(peer->cid_num) && !ast_strlen_zero(p->cid_num)) {
- ast_string_field_set(p, cid_num, peer->cid_num);
- ast_shrink_phone_number((char *) p->cid_num);
+ char *tmp = ast_strdupa(peer->cid_num);
+ if (tmp) {
+ ast_shrink_phone_number(tmp);
+ ast_string_field_set(p, cid_num, tmp);
+ } else {
+ ast_string_field_set(p, cid_num, peer->cid_num);
+ }
}
if (!ast_strlen_zero(peer->cid_name) && !ast_strlen_zero(p->cid_name))
ast_string_field_set(p, cid_name, peer->cid_name);
More information about the svn-commits
mailing list