[svn-commits] russell: trunk r287896 - in /trunk: ./ channels/ main/ res/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Sep 21 10:45:51 CDT 2010


Author: russell
Date: Tue Sep 21 10:45:46 2010
New Revision: 287896

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=287896
Log:
Merged revisions 287895 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r287895 | russell | 2010-09-21 10:43:33 -0500 (Tue, 21 Sep 2010) | 10 lines
  
  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:
    trunk/   (props changed)
    trunk/channels/chan_sip.c
    trunk/main/acl.c
    trunk/main/dnsmgr.c
    trunk/res/res_rtp_asterisk.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=287896&r1=287895&r2=287896
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Tue Sep 21 10:45:46 2010
@@ -13864,6 +13864,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"
@@ -13871,8 +13873,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:
@@ -13886,6 +13887,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"
@@ -13895,14 +13898,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"
@@ -13910,13 +13914,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"
@@ -13926,8 +13930,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);
 					}
 				}
 			}
@@ -16937,9 +16940,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");
@@ -27332,8 +27335,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: trunk/main/acl.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/acl.c?view=diff&rev=287896&r1=287895&r2=287896
==============================================================================
--- trunk/main/acl.c (original)
+++ trunk/main/acl.c Tue Sep 21 10:45:46 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: trunk/main/dnsmgr.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/dnsmgr.c?view=diff&rev=287896&r1=287895&r2=287896
==============================================================================
--- trunk/main/dnsmgr.c (original)
+++ trunk/main/dnsmgr.c Tue Sep 21 10:45:46 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: trunk/res/res_rtp_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_rtp_asterisk.c?view=diff&rev=287896&r1=287895&r2=287896
==============================================================================
--- trunk/res/res_rtp_asterisk.c (original)
+++ trunk/res/res_rtp_asterisk.c Tue Sep 21 10:45:46 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 svn-commits mailing list