Browse Source

parse_uri cleanup.

Jan Janak 23 years ago
parent
commit
dc85e6e9f9
2 changed files with 10 additions and 11 deletions
  1. 6 1
      modules/tm/tm.c
  2. 4 10
      modules/tm/ut.h

+ 6 - 1
modules/tm/tm.c

@@ -360,6 +360,7 @@ inline static int fixup_hostport2proxy(void** param, int param_no)
 	char *host;
 	int err;
 	struct proxy_l *proxy;
+	str s;
 	
 	DBG("TM module: fixup_t_forward(%s, %d)\n", (char*)*param, param_no);
 	if (param_no==1){
@@ -374,13 +375,17 @@ inline static int fixup_hostport2proxy(void** param, int param_no)
 				(char*)(*param));
 			 return E_UNSPEC;
 		}
-		proxy=mk_proxy(host, port);
+		s.s = host;
+		s.len = strlen(host);
+		proxy=mk_proxy(&s, port);
 		if (proxy==0) {
 			LOG(L_ERR, "ERROR: fixup_t_forwardv6: bad host name in URI <%s>\n",
 				host );
 			return E_BAD_ADDRESS;
 		}
 		/* success -- fix the first parameter to proxy now ! */
+
+		/* FIXME: janakj, mk_proxy doesn't make copy of host !! */
 		free( *(param-1));
 		*(param-1)=proxy;
 		return 0;

+ 4 - 10
modules/tm/ut.h

@@ -40,7 +40,7 @@
 
 inline static struct proxy_l *uri2proxy( str *uri )
 {
-	struct sip_uri  parsed_uri;
+	struct sip_uri parsed_uri;
 	unsigned int  port; 
 	struct proxy_l *p;
 	int err;
@@ -55,24 +55,18 @@ inline static struct proxy_l *uri2proxy( str *uri )
 		if (err){
 			LOG(L_ERR, "ERROR: t_relay: bad port in uri: <%.*s>\n",
 				parsed_uri.port.len, parsed_uri.port.s);
-			goto error;
+			return 0;
 		}
 	/* fixed use of SRV resolver
 	} else port=SIP_PORT; */
 	} else port=0;
-	p=mk_proxy(parsed_uri.host.s, port);
+	p=mk_proxy(&(parsed_uri.host), port);
 	if (p==0) {
 		LOG(L_ERR, "ERROR: t_relay: bad host name in URI <%.*s>\n",
 			uri->len, uri->s);
-		goto error;
+		return 0;
 	}
-	free_uri( &parsed_uri );
 	return p;
-
-error:
-	free_uri( &parsed_uri );
-	return 0;
-	
 }
 
 #endif