[asterisk-commits] bbryant: branch bbryant/ssl-tcp-tls r71041 - /team/bbryant/ssl-tcp-tls/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jun 21 23:46:57 CDT 2007


Author: bbryant
Date: Thu Jun 21 23:46:57 2007
New Revision: 71041

URL: http://svn.digium.com/view/asterisk?view=rev&rev=71041
Log:
Stack > Heap

Modified:
    team/bbryant/ssl-tcp-tls/channels/chan_sip.c

Modified: team/bbryant/ssl-tcp-tls/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/bbryant/ssl-tcp-tls/channels/chan_sip.c?view=diff&rev=71041&r1=71040&r2=71041
==============================================================================
--- team/bbryant/ssl-tcp-tls/channels/chan_sip.c (original)
+++ team/bbryant/ssl-tcp-tls/channels/chan_sip.c Thu Jun 21 23:46:57 2007
@@ -1294,7 +1294,7 @@
 static int sip_senddigit_begin(struct ast_channel *ast, char digit);
 static int sip_senddigit_end(struct ast_channel *ast, char digit, unsigned int duration);
 
-static char *get_transport(struct sip_pvt *p);
+#define get_transport(p) ( ( p->transport & SIP_TRANSPORT_UDP ) ? "UDP" : ( p->transport & SIP_TRANSPORT_TCP ) ? "TCP" : "TLS" )
 static int handle_request_do(struct sip_pvt *p, struct sip_request *req, struct sockaddr_in *sin, int *nounlock);
 
 /*--- Transmitting responses and requests */
@@ -3394,18 +3394,14 @@
 
 		if (!(p->transport & SIP_TRANSPORT_UDP)) {
 			char name[256];
-			struct server_args *ca = ast_calloc(1, sizeof(*ca));
-
-			if(!ca)
-				return -1;
-
-			snprintf(name, sizeof(name), "SIP Call to %s", p->peername);
-
-			ca->name = ast_strdup(name);
-			ca->accept_fd = -1;
-			ca->tls_cfg = (p->ser) ? p->ser->parent->tls_cfg : NULL;
-			ca->sin = p->sa;
-			p->ser = (!p->ser) ? client_start(ca) : p->ser;
+			struct server_args ca;
+
+			snprintf(ca.name, sizeof(ca.name), "SIP Call to %s", p->peername);
+
+			ca.accept_fd = -1;
+			ca.tls_cfg = (p->ser) ? p->ser->parent->tls_cfg : NULL;
+			ca.sin = p->sa;
+			p->ser = (!p->ser) ? client_start(&ca) : p->ser;
 
 			if (!p->ser)
 				return -1;
@@ -3413,8 +3409,8 @@
 			p->fd = ca->accept_fd;
 
 			if (ast_pthread_create_background(&ca->master, NULL, sip_tcp_helper_thread, p->ser)) {
-				ast_debug(1, "Unable to launch '%s'.", ca->name);
-				close(ca->accept_fd);
+				ast_debug(1, "Unable to launch '%s'.", ca.name);
+				close(ca.accept_fd);
 				p->fd = ca->accept_fd = -1;
 				return -1;
 			}
@@ -15955,11 +15951,6 @@
 	return 1;
 }
 
-static char *get_transport(struct sip_pvt *p) {
-	char *str = (p->transport & SIP_TRANSPORT_UDP) ? "UDP" : (p->transport & SIP_TRANSPORT_TCP) ? "TCP" : "TLS";
-	return ast_strdup(str);
-}
-
 static int handle_request_do(struct sip_pvt *p, struct sip_request *req, struct sockaddr_in *sin, int *nounlock) {
 	int recount = 0;
 




More information about the asterisk-commits mailing list