[asterisk-commits] branch 1.2 r28337 - /branches/1.2/enum.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu May 18 12:35:55 MST 2006


Author: kpfleming
Date: Thu May 18 14:35:55 2006
New Revision: 28337

URL: http://svn.digium.com/view/asterisk?rev=28337&view=rev
Log:
use unsigned counters for handling answer/IE lengths while processing DNS results (issue #7174)

Modified:
    branches/1.2/enum.c

Modified: branches/1.2/enum.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/enum.c?rev=28337&r1=28336&r2=28337&view=diff
==============================================================================
--- branches/1.2/enum.c (original)
+++ branches/1.2/enum.c Thu May 18 14:35:55 2006
@@ -80,27 +80,29 @@
 } __attribute__ ((__packed__));
 
 /*--- parse_ie: Parse NAPTR record information elements */
-static int parse_ie(char *data, int maxdatalen, char *src, int srclen)
-{
-	int len, olen;
-
-	len = olen = (int)src[0];
+static unsigned int parse_ie(char *data, unsigned int maxdatalen, char *src, unsigned int srclen)
+{
+	unsigned int len, olen;
+
+	len = olen = (unsigned int) src[0];
 	src++;
 	srclen--;
-	if (len > srclen || len < 0 ) {
+
+	if (len > srclen) {
 		ast_log(LOG_WARNING, "ENUM parsing failed: Wanted %d characters, got %d\n", len, srclen);
 		return -1;
 	}
+
 	if (len > maxdatalen)
 		len = maxdatalen;
 	memcpy(data, src, len);
+
 	return olen + 1;
 }
 
 /*--- parse_naptr: Parse DNS NAPTR record used in ENUM ---*/
 static int parse_naptr(char *dst, int dstsize, char *tech, int techsize, char *answer, int len, char *naptrinput)
 {
-
 	char tech_return[80];
 	char *oanswer = answer;
 	char flags[512] = "";
@@ -344,7 +346,7 @@
 /*--- enum_callback: Callback from ENUM lookup function */
 static int enum_callback(void *context, char *answer, int len, char *fullanswer)
 {
-	struct enum_context *c = (struct enum_context *)context;
+       struct enum_context *c = (struct enum_context *)context;
        void *p = NULL;
        int res;
 



More information about the asterisk-commits mailing list