[asterisk-commits] mmichelson: trunk r276570 - in /trunk: channels/ main/ res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jul 14 17:32:33 CDT 2010


Author: mmichelson
Date: Wed Jul 14 17:32:29 2010
New Revision: 276570

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=276570
Log:
Fix errors where incorrect address information was printed.

ast_sockaddr_stringiy_fmt (which is call by all ast_sockaddr_stringify* functions)
uses thread-local storage for storing the string that it creates. In cases where
ast_sockaddr_stringify_fmt was being called twice within the same statement, the
result of one call would be overwritten by the result of the other call. This
usually was happening in printf-like statements and was resulting in the same
stringified addressed being printed twice instead of two separate addresses.

I have fixed this by using ast_strdupa on the result of stringify functions if
they are used twice within the same statement. As far as I could tell, there were
no instances where a pointer to the result of such a call were saved anywhere, so
this is the only situation I could see where this error could occur.


Modified:
    trunk/channels/chan_sip.c
    trunk/main/acl.c
    trunk/main/dnsmgr.c
    trunk/res/res_rtp_asterisk.c

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=276570&r1=276569&r2=276570
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Wed Jul 14 17:32:29 2010
@@ -13427,8 +13427,8 @@
 					      "Cause: AUTH_SECRET_FAILED\r\n"
 					      "Address: %s\r\n"
 					      "Port: %s\r\n",
-					      name, ast_sockaddr_stringify_addr(addr),
-					      ast_sockaddr_stringify_port(addr));
+					      name, ast_strdupa(ast_sockaddr_stringify_addr(addr)),
+					      ast_strdupa(ast_sockaddr_stringify_port(addr)));
 			}
 			break;
 		case AUTH_USERNAME_MISMATCH:
@@ -13451,8 +13451,8 @@
 						      "Port: %s\r\n",
 						      name,
 						      res == AUTH_PEER_NOT_DYNAMIC ? "AUTH_PEER_NOT_DYNAMIC" : "URI_NOT_FOUND",
-						      ast_sockaddr_stringify_addr(addr),
-						      ast_sockaddr_stringify_port(addr));
+						      ast_strdupa(ast_sockaddr_stringify_addr(addr)),
+						      ast_strdupa(ast_sockaddr_stringify_port(addr)));
 				}
 			} else {
 				/* URI not found */
@@ -13467,8 +13467,8 @@
 							"Address: %s\r\n"
 							"Port: %s\r\n",
 							name,
-							ast_sockaddr_stringify_addr(addr),
-							ast_sockaddr_stringify_port(addr));
+							ast_strdupa(ast_sockaddr_stringify_addr(addr)),
+							ast_strdupa(ast_sockaddr_stringify_port(addr)));
 					}
 				} else {
 					transmit_response(p, "404 Not found", &p->initreq);
@@ -13482,8 +13482,8 @@
 							"Port: %s\r\n",
 							name,
 							(res == AUTH_USERNAME_MISMATCH) ? "AUTH_USERNAME_MISMATCH" : "URI_NOT_FOUND",
-							ast_sockaddr_stringify_addr(addr),
-							ast_sockaddr_stringify_port(addr));
+							ast_strdupa(ast_sockaddr_stringify_addr(addr)),
+							ast_strdupa(ast_sockaddr_stringify_port(addr)));
 					}
 				}
 			}
@@ -27009,7 +27009,7 @@
 
 	if ((res = ast_apply_ha(p->directmediaha, &them_sin)) == AST_SENSE_DENY) {
 		ast_debug(3, "Reinvite %s to %s denied by directmedia ACL on %s\n",
-			op, ast_sockaddr_stringify(&them), ast_sockaddr_stringify(&us));
+			op, ast_strdupa(ast_sockaddr_stringify(&them)), ast_strdupa(ast_sockaddr_stringify(&us)));
 	}
 
 	return res;

Modified: trunk/main/acl.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/acl.c?view=diff&rev=276570&r1=276569&r2=276570
==============================================================================
--- trunk/main/acl.c (original)
+++ trunk/main/acl.c Wed Jul 14 17:32:29 2010
@@ -529,8 +529,8 @@
 	}
 	close(s);
 	ast_debug(3, "For destination '%s', our source address is '%s'.\n",
-		  ast_sockaddr_stringify_addr(them),
-		  ast_sockaddr_stringify_addr(us));
+		  ast_strdupa(ast_sockaddr_stringify_addr(them)),
+		  ast_strdupa(ast_sockaddr_stringify_addr(us)));
 
 	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=276570&r1=276569&r2=276570
==============================================================================
--- trunk/main/dnsmgr.c (original)
+++ trunk/main/dnsmgr.c Wed Jul 14 17:32:29 2010
@@ -161,8 +161,8 @@
 			ast_sockaddr_set_port(&tmp, ast_sockaddr_port(entry->result));
 		if (ast_sockaddr_cmp(&tmp, entry->result)) {
 			ast_log(LOG_NOTICE, "dnssrv: host '%s' changed from %s to %s\n",
-					entry->name, ast_sockaddr_stringify(entry->result),
-					ast_sockaddr_stringify(&tmp));
+					entry->name, ast_strdupa(ast_sockaddr_stringify(entry->result)),
+					ast_strdupa(ast_sockaddr_stringify(&tmp)));
 
 			ast_sockaddr_copy(entry->result, &tmp);
 			changed = entry->changed = 1;

Modified: trunk/res/res_rtp_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_rtp_asterisk.c?view=diff&rev=276570&r1=276569&r2=276570
==============================================================================
--- trunk/res/res_rtp_asterisk.c (original)
+++ trunk/res/res_rtp_asterisk.c Wed Jul 14 17:32:29 2010
@@ -1999,8 +1999,8 @@
 						  &addr);
 			} else  {
 				ast_debug(1, "Received RTP packet from %s, dropping due to strict RTP protection. Expected it to be from %s\n",
-					  ast_sockaddr_stringify(&addr),
-					  ast_sockaddr_stringify(&rtp->strict_rtp_address));
+					  ast_strdupa(ast_sockaddr_stringify(&addr)),
+					  ast_strdupa(ast_sockaddr_stringify(&rtp->strict_rtp_address)));
 				return &ast_null_frame;
 			}
 		}




More information about the asterisk-commits mailing list