[asterisk-commits] russell: branch 1.8 r287895 - in /branches/1.8: channels/ main/ res/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Sep 21 10:43:39 CDT 2010
Author: russell
Date: Tue Sep 21 10:43:33 2010
New Revision: 287895
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=287895
Log:
Don't use ast_strdupa() from within the arguments to a function.
(closes issue #17902)
Reported by: afried
Patches:
issue_17902.rev1.txt uploaded by russell (license 2)
Tested by: russell
Review: https://reviewboard.asterisk.org/r/927/
Modified:
branches/1.8/channels/chan_sip.c
branches/1.8/main/acl.c
branches/1.8/main/dnsmgr.c
branches/1.8/res/res_rtp_asterisk.c
Modified: branches/1.8/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/chan_sip.c?view=diff&rev=287895&r1=287894&r2=287895
==============================================================================
--- branches/1.8/channels/chan_sip.c (original)
+++ branches/1.8/channels/chan_sip.c Tue Sep 21 10:43:33 2010
@@ -13837,6 +13837,8 @@
/* Wrong password in authentication. Go away, don't try again until you fixed it */
transmit_response(p, "403 Forbidden (Bad auth)", &p->initreq);
if (global_authfailureevents) {
+ const char *peer_addr = ast_strdupa(ast_sockaddr_stringify_addr(addr));
+ const char *peer_port = ast_strdupa(ast_sockaddr_stringify_port(addr));
manager_event(EVENT_FLAG_SYSTEM, "PeerStatus",
"ChannelType: SIP\r\n"
"Peer: SIP/%s\r\n"
@@ -13844,8 +13846,7 @@
"Cause: AUTH_SECRET_FAILED\r\n"
"Address: %s\r\n"
"Port: %s\r\n",
- name, ast_strdupa(ast_sockaddr_stringify_addr(addr)),
- ast_strdupa(ast_sockaddr_stringify_port(addr)));
+ name, peer_addr, peer_port);
}
break;
case AUTH_USERNAME_MISMATCH:
@@ -13859,6 +13860,8 @@
if (sip_cfg.alwaysauthreject) {
transmit_fake_auth_response(p, SIP_REGISTER, &p->initreq, XMIT_UNRELIABLE);
if (global_authfailureevents) {
+ const char *peer_addr = ast_strdupa(ast_sockaddr_stringify_addr(addr));
+ const char *peer_port = ast_strdupa(ast_sockaddr_stringify_port(addr));
manager_event(EVENT_FLAG_SYSTEM, "PeerStatus",
"ChannelType: SIP\r\n"
"Peer: SIP/%s\r\n"
@@ -13868,14 +13871,15 @@
"Port: %s\r\n",
name,
res == AUTH_PEER_NOT_DYNAMIC ? "AUTH_PEER_NOT_DYNAMIC" : "URI_NOT_FOUND",
- ast_strdupa(ast_sockaddr_stringify_addr(addr)),
- ast_strdupa(ast_sockaddr_stringify_port(addr)));
+ peer_addr, peer_port);
}
} else {
/* URI not found */
if (res == AUTH_PEER_NOT_DYNAMIC) {
transmit_response(p, "403 Forbidden", &p->initreq);
if (global_authfailureevents) {
+ const char *peer_addr = ast_strdupa(ast_sockaddr_stringify_addr(addr));
+ const char *peer_port = ast_strdupa(ast_sockaddr_stringify_port(addr));
manager_event(EVENT_FLAG_SYSTEM, "PeerStatus",
"ChannelType: SIP\r\n"
"Peer: SIP/%s\r\n"
@@ -13883,13 +13887,13 @@
"Cause: AUTH_PEER_NOT_DYNAMIC\r\n"
"Address: %s\r\n"
"Port: %s\r\n",
- name,
- ast_strdupa(ast_sockaddr_stringify_addr(addr)),
- ast_strdupa(ast_sockaddr_stringify_port(addr)));
+ name, peer_addr, peer_port);
}
} else {
transmit_response(p, "404 Not found", &p->initreq);
if (global_authfailureevents) {
+ const char *peer_addr = ast_strdupa(ast_sockaddr_stringify_addr(addr));
+ const char *peer_port = ast_strdupa(ast_sockaddr_stringify_port(addr));
manager_event(EVENT_FLAG_SYSTEM, "PeerStatus",
"ChannelType: SIP\r\n"
"Peer: SIP/%s\r\n"
@@ -13899,8 +13903,7 @@
"Port: %s\r\n",
name,
(res == AUTH_USERNAME_MISMATCH) ? "AUTH_USERNAME_MISMATCH" : "URI_NOT_FOUND",
- ast_strdupa(ast_sockaddr_stringify_addr(addr)),
- ast_strdupa(ast_sockaddr_stringify_port(addr)));
+ peer_addr, peer_port);
}
}
}
@@ -16908,9 +16911,9 @@
const char *prefix = "Localnet:";
for (d = localaddr; d ; prefix = "", d = d->next) {
- ast_cli(a->fd, " %-24s%s/%s\n",
- prefix, ast_strdupa(ast_sockaddr_stringify_addr(&d->addr)),
- ast_strdupa(ast_sockaddr_stringify_addr(&d->netmask)));
+ const char *addr = ast_strdupa(ast_sockaddr_stringify_addr(&d->addr));
+ const char *mask = ast_strdupa(ast_sockaddr_stringify_addr(&d->netmask));
+ ast_cli(a->fd, " %-24s%s/%s\n", prefix, addr, mask);
}
}
ast_cli(a->fd, "\nGlobal Signalling Settings:\n");
@@ -27274,8 +27277,11 @@
ast_rtp_instance_get_local_address(p->rtp, &us);
if ((res = ast_apply_ha(p->directmediaha, &them)) == AST_SENSE_DENY) {
+ const char *us_addr = ast_strdupa(ast_sockaddr_stringify(&us));
+ const char *them_addr = ast_strdupa(ast_sockaddr_stringify(&them));
+
ast_debug(3, "Reinvite %s to %s denied by directmedia ACL on %s\n",
- op, ast_strdupa(ast_sockaddr_stringify(&them)), ast_strdupa(ast_sockaddr_stringify(&us)));
+ op, them_addr, us_addr);
}
return res;
Modified: branches/1.8/main/acl.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/acl.c?view=diff&rev=287895&r1=287894&r2=287895
==============================================================================
--- branches/1.8/main/acl.c (original)
+++ branches/1.8/main/acl.c Tue Sep 21 10:43:33 2010
@@ -488,7 +488,12 @@
ret = ha;
}
- ast_debug(1, "%s/%s sense %d appended to acl for peer\n", ast_strdupa(ast_sockaddr_stringify(&ha->addr)), ast_strdupa(ast_sockaddr_stringify(&ha->netmask)), ha->sense);
+ {
+ const char *addr = ast_strdupa(ast_sockaddr_stringify(&ha->addr));
+ const char *mask = ast_strdupa(ast_sockaddr_stringify(&ha->netmask));
+
+ ast_debug(1, "%s/%s sense %d appended to acl for peer\n", addr, mask, ha->sense);
+ }
return ret;
}
@@ -701,9 +706,14 @@
return -1;
}
close(s);
- ast_debug(3, "For destination '%s', our source address is '%s'.\n",
- ast_strdupa(ast_sockaddr_stringify_addr(them)),
- ast_strdupa(ast_sockaddr_stringify_addr(us)));
+
+ {
+ const char *them_addr = ast_strdupa(ast_sockaddr_stringify_addr(them));
+ const char *us_addr = ast_strdupa(ast_sockaddr_stringify_addr(us));
+
+ ast_debug(3, "For destination '%s', our source address is '%s'.\n",
+ them_addr, us_addr);
+ }
ast_sockaddr_set_port(us, port);
Modified: branches/1.8/main/dnsmgr.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/dnsmgr.c?view=diff&rev=287895&r1=287894&r2=287895
==============================================================================
--- branches/1.8/main/dnsmgr.c (original)
+++ branches/1.8/main/dnsmgr.c Tue Sep 21 10:43:33 2010
@@ -151,22 +151,26 @@
*/
static int dnsmgr_refresh(struct ast_dnsmgr_entry *entry, int verbose)
{
- struct ast_sockaddr tmp;
+ struct ast_sockaddr tmp = { .len = 0, };
int changed = 0;
ast_mutex_lock(&entry->lock);
- if (verbose)
+
+ if (verbose) {
ast_verb(3, "refreshing '%s'\n", entry->name);
-
- memset(&tmp, 0, sizeof(tmp));
+ }
if (!ast_get_ip_or_srv(&tmp, entry->name, entry->service)) {
- if (!ast_sockaddr_port(&tmp))
+ if (!ast_sockaddr_port(&tmp)) {
ast_sockaddr_set_port(&tmp, ast_sockaddr_port(entry->result));
+ }
+
if (ast_sockaddr_cmp(&tmp, entry->result)) {
+ const char *old_addr = ast_strdupa(ast_sockaddr_stringify(entry->result));
+ const char *new_addr = ast_strdupa(ast_sockaddr_stringify(&tmp));
+
ast_log(LOG_NOTICE, "dnssrv: host '%s' changed from %s to %s\n",
- entry->name, ast_strdupa(ast_sockaddr_stringify(entry->result)),
- ast_strdupa(ast_sockaddr_stringify(&tmp)));
+ entry->name, old_addr, new_addr);
ast_sockaddr_copy(entry->result, &tmp);
changed = entry->changed = 1;
@@ -174,6 +178,7 @@
}
ast_mutex_unlock(&entry->lock);
+
return changed;
}
Modified: branches/1.8/res/res_rtp_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/res/res_rtp_asterisk.c?view=diff&rev=287895&r1=287894&r2=287895
==============================================================================
--- branches/1.8/res/res_rtp_asterisk.c (original)
+++ branches/1.8/res/res_rtp_asterisk.c Tue Sep 21 10:43:33 2010
@@ -2012,9 +2012,12 @@
ast_sockaddr_copy(&rtp->strict_rtp_address,
&addr);
} else {
+ const char *real_addr = ast_strdupa(ast_sockaddr_stringify(&addr));
+ const char *expected_addr = ast_strdupa(ast_sockaddr_stringify(&rtp->strict_rtp_address));
+
ast_debug(1, "Received RTP packet from %s, dropping due to strict RTP protection. Expected it to be from %s\n",
- ast_strdupa(ast_sockaddr_stringify(&addr)),
- ast_strdupa(ast_sockaddr_stringify(&rtp->strict_rtp_address)));
+ real_addr, expected_addr);
+
return &ast_null_frame;
}
}
More information about the asterisk-commits
mailing list