[Freeswitch-svn] [commit] r7909 - freeswitch/trunk/src/mod/applications/mod_enum

Freeswitch SVN anthm at freeswitch.org
Mon Mar 17 23:24:03 EDT 2008


Author: anthm
Date: Mon Mar 17 23:24:03 2008
New Revision: 7909

Modified:
   freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c

Log:
resolve MODAPP-80

Modified: freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c	Mon Mar 17 23:24:03 2008
@@ -279,46 +279,57 @@
 	const unsigned char *dend = rr->dnsrr_dend;
 	unsigned char *dn = rr->dnsrr_dn;
 	const unsigned char *c;
-	char *ptr;
 	char flags;
 	int order;
 	int preference;
-	char *nme;
 	char *service = NULL;
 	char *regex = NULL;
 	char *replace = NULL;
 	int argc = 0;
 	char *argv[4] = { 0 };
-	int leap;
+	int n;
+	char string_arg[3][256] = {{0}};
 
 	switch (rr->dnsrr_typ) {
-
-	case DNS_T_NAPTR:			/* prio weight port targetDN */
+	case DNS_T_NAPTR:/* prio weight port targetDN */
 		c = dptr;
-		c += 2 + 2 + 2;
-		if (dns_getdn(pkt, &c, end, dn, DNS_MAXDN) <= 0 || c != dend)
+		c += 4; /* order, pref */
+
+		for (n = 0; n < 3; ++n) {
+			if (c >= dend) {
+				goto xperr;
+			} else { 
+				c += *c + 1;
+			}
+		}
+
+		if (dns_getdn(pkt, &c, end, dn, DNS_MAXDN) <= 0 || c != dend) {
 			goto xperr;
+		}
+
 		c = dptr;
+		order = dns_get16(c+0);
+		preference = dns_get16(c+2);
+		flags = (char) dns_get16(c + 4);
+		c += 4;
 
-		leap = *dn;
-		nme = (char *) dn + 1;
+		for(n = 0; n < 3; n++) {
+			uint32_t len = *c++, cpylen = len;
+			if (len > sizeof(string_arg[n]) - 1) {
+				cpylen = sizeof(string_arg[n]) - 1;
+			}
+			strncpy(string_arg[n], (char *)c, cpylen);
+			*(string_arg[n] + len) = '\0';
+			c += len;
+		}
 
-		order = dns_get16(c + 0);
-		preference = dns_get16(c + 2);
-		flags = (char) dns_get16(c + 4);
+		service = string_arg[1];
 
-		if ((ptr = nme + leap)) {
-			service = nme;
-			*ptr++ = '\0';
-			argc = switch_separate_string(ptr, '!', argv, (sizeof(argv) / sizeof(argv[0])));
+		if ((argc = switch_separate_string(string_arg[2], '!', argv, (sizeof(argv) / sizeof(argv[0]))))) {
 			regex = argv[1];
 			replace = argv[2];
-		}
-
-		for (ptr = replace; ptr && *ptr; ptr++) {
-			if (*ptr == '\\') {
-				*ptr = '$';
-			}
+		} else {
+			goto xperr;
 		}
 
 		if (flags && service && regex && replace) {
@@ -350,7 +361,7 @@
 						}
 					}
 				}
-
+				
 				add_result(q, order, preference, service, uri);
 			}
 
@@ -365,7 +376,7 @@
 
 	return;
 
-  xperr:
+	xperr:
 	//printf("<parse error>\n");
 	return;
 }



More information about the Freeswitch-svn mailing list