[asterisk-commits] russell: branch 1.2 r110335 - in /branches/1.2/channels: chan_iax2.c chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Mar 20 16:53:28 CDT 2008


Author: russell
Date: Thu Mar 20 16:53:27 2008
New Revision: 110335

URL: http://svn.digium.com/view/asterisk?view=rev&rev=110335
Log:
Fix some very broken code that was introduced in 1.2.26 as a part of the security
fix.  The dnsmgr is not appropriate here.  The dnsmgr takes a pointer to an address
structure that a background thread continuously updates.  However, in these cases,
a stack variable was passed.  That means that the dnsmgr thread would be continuously
writing to bogus memory.

Modified:
    branches/1.2/channels/chan_iax2.c
    branches/1.2/channels/chan_sip.c

Modified: branches/1.2/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_iax2.c?view=diff&rev=110335&r1=110334&r2=110335
==============================================================================
--- branches/1.2/channels/chan_iax2.c (original)
+++ branches/1.2/channels/chan_iax2.c Thu Mar 20 16:53:27 2008
@@ -2657,9 +2657,9 @@
 		if (var && sin) {
 			for (tmp = var; tmp; tmp = tmp->next) {
 				if (!strcasecmp(tmp->name, "host")) {
-					struct in_addr sin2 = { 0, };
-					struct ast_dnsmgr_entry *dnsmgr = NULL;
-					if ((ast_dnsmgr_lookup(tmp->value, &sin2, &dnsmgr) < 0) || (memcmp(&sin2, &sin->sin_addr, sizeof(sin2)) != 0)) {
+					struct ast_hostent ahp;
+					struct hostent *hp;
+					if (!(hp = ast_gethostbyname(tmp->value, &ahp)) || (memcmp(&hp->h_addr, &sin->sin_addr, sizeof(hp->h_addr)))) {
 						/* No match */
 						ast_variables_destroy(var);
 						var = NULL;
@@ -2773,9 +2773,9 @@
 		if (var) {
 			for (tmp = var; tmp; tmp = tmp->next) {
 				if (!strcasecmp(tmp->name, "host")) {
-					struct in_addr sin2 = { 0, };
-					struct ast_dnsmgr_entry *dnsmgr = NULL;
-					if ((ast_dnsmgr_lookup(tmp->value, &sin2, &dnsmgr) < 0) || (memcmp(&sin2, &sin->sin_addr, sizeof(sin2)) != 0)) {
+					struct ast_hostent ahp;
+					struct hostent *hp;
+					if (!(hp = ast_gethostbyname(tmp->value, &ahp)) || (memcmp(&hp->h_addr, &sin->sin_addr, sizeof(hp->h_addr)))) {
 						/* No match */
 						ast_variables_destroy(var);
 						var = NULL;

Modified: branches/1.2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_sip.c?view=diff&rev=110335&r1=110334&r2=110335
==============================================================================
--- branches/1.2/channels/chan_sip.c (original)
+++ branches/1.2/channels/chan_sip.c Thu Mar 20 16:53:27 2008
@@ -78,10 +78,8 @@
 #include "asterisk/utils.h"
 #include "asterisk/file.h"
 #include "asterisk/astobj.h"
-#include "asterisk/dnsmgr.h"
 #include "asterisk/devicestate.h"
 #include "asterisk/linkedlists.h"
-#include "asterisk/dnsmgr.h"
 
 #ifdef OSP_SUPPORT
 #include "asterisk/astosp.h"
@@ -789,7 +787,6 @@
 	int rtpkeepalive;		/*!<  Send RTP packets for keepalive */
 	ast_group_t callgroup;		/*!<  Call group */
 	ast_group_t pickupgroup;	/*!<  Pickup group */
-	struct ast_dnsmgr_entry *dnsmgr;/*!<  DNS refresh manager for peer */
 	struct sockaddr_in addr;	/*!<  IP address of peer */
 
 	/* Qualification */
@@ -1672,8 +1669,6 @@
 		speerobjs--;
 	clear_realm_authentication(peer->auth);
 	peer->auth = (struct sip_auth *) NULL;
-	if (peer->dnsmgr)
-		ast_dnsmgr_release(peer->dnsmgr);
 	free(peer);
 }
 
@@ -1714,9 +1709,9 @@
 			if (var) {
 				for (tmp = var; tmp; tmp = tmp->next) {
 					if (!strcasecmp(var->name, "host")) {
-						struct in_addr sin2 = { 0, };
-						struct ast_dnsmgr_entry *dnsmgr = NULL;
-						if ((ast_dnsmgr_lookup(tmp->value, &sin2, &dnsmgr) < 0) || (memcmp(&sin2, &sin->sin_addr, sizeof(sin2)) != 0)) {
+						struct hostent *hp;
+						struct ast_hostent ahp;
+						if (!(hp = ast_gethostbyname(tmp->value, &ahp)) || (memcmp(&hp->h_addr, &sin->sin_addr, sizeof(hp->h_addr)))) {
 							/* No match */
 							ast_variables_destroy(var);
 							var = NULL;




More information about the asterisk-commits mailing list