[Asterisk-cvs] asterisk acl.c,1.15.2.1,1.15.2.2 asterisk.c,1.51.2.13,1.51.2.14 pbx.c,1.96.2.9,1.96.2.10

markster at lists.digium.com markster at lists.digium.com
Wed Apr 21 20:45:29 CDT 2004


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv20221

Modified Files:
      Tag: v1-0_stable
	acl.c asterisk.c pbx.c 
Log Message:
Backport gethostbyname_r conversion


Index: acl.c
===================================================================
RCS file: /usr/cvsroot/asterisk/acl.c,v
retrieving revision 1.15.2.1
retrieving revision 1.15.2.2
diff -u -d -r1.15.2.1 -r1.15.2.2
--- acl.c	20 Mar 2004 19:08:45 -0000	1.15.2.1
+++ acl.c	22 Apr 2004 00:50:10 -0000	1.15.2.2
@@ -139,7 +139,8 @@
 int ast_get_ip(struct sockaddr_in *sin, char *value)
 {
 	struct hostent *hp;
-	hp = gethostbyname(value);
+	struct ast_hostent ahp;
+	hp = ast_gethostbyname(value, &ahp);
 	if (hp) {
 		memcpy(&sin->sin_addr, hp->h_addr, sizeof(sin->sin_addr));
 	} else {

Index: asterisk.c
===================================================================
RCS file: /usr/cvsroot/asterisk/asterisk.c,v
retrieving revision 1.51.2.13
retrieving revision 1.51.2.14
diff -u -d -r1.51.2.13 -r1.51.2.14
--- asterisk.c	9 Apr 2004 17:46:10 -0000	1.51.2.13
+++ asterisk.c	22 Apr 2004 00:50:10 -0000	1.51.2.14
@@ -45,6 +45,7 @@
 #include "editline/histedit.h"
 #include "asterisk.h"
 #include <asterisk/config.h>
+#include <asterisk/lock.h>
 
 #define AST_MAX_CONNECTS 128
 #define NUM_MSGS 64
@@ -1545,4 +1546,16 @@
 		ast_select(0,NULL,NULL,NULL,NULL);
 	}
 	return 0;
+}
+
+struct hostent *ast_gethostbyname(const char *host, struct ast_hostent *hp)
+{
+	int res;
+	int h_errno;
+	struct hostent *result = NULL;
+	/* XXX Does BSD do this differently? XXX */
+	res = gethostbyname_r(host, &hp->hp, hp->buf, sizeof(hp->buf), &result, &h_errno);
+	if (res)
+		return NULL;
+	return &hp->hp;
 }

Index: pbx.c
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx.c,v
retrieving revision 1.96.2.9
retrieving revision 1.96.2.10
diff -u -d -r1.96.2.9 -r1.96.2.10
--- pbx.c	19 Mar 2004 06:35:51 -0000	1.96.2.9
+++ pbx.c	22 Apr 2004 00:50:10 -0000	1.96.2.10
@@ -4348,7 +4348,7 @@
 		ast_log(LOG_WARNING, "Goto requires an argument (optional context|optional extension|priority)\n");
 		return -1;
 	}
-	s = strdup((void *) data);
+	s = ast_strdupa((void *) data);
 	stringp=s;
 	context = strsep(&stringp, "|");
 	exten = strsep(&stringp, "|");
@@ -4368,7 +4368,6 @@
 	}
 	if (atoi(pri) < 0) {
 		ast_log(LOG_WARNING, "Priority '%s' must be a number > 0\n", pri);
-		free(s);
 		return -1;
 	}
 	/* At this point we have a priority and maybe an extension and a context */




More information about the svn-commits mailing list