httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Slemko <ma...@znep.com>
Subject [PATCH] fix strtoul
Date Fri, 14 Nov 1997 03:30:24 GMT
Index: proxy_util.c
===================================================================
RCS file: /export/home/cvs/apachen/src/modules/proxy/proxy_util.c,v
retrieving revision 1.35
diff -u -r1.35 proxy_util.c
--- proxy_util.c	1997/11/01 21:13:24	1.35
+++ proxy_util.c	1997/11/14 03:23:16
@@ -867,9 +867,9 @@
 int proxy_is_ipaddr(struct dirconn_entry *This)
 {
     const char *addr = This->name;
-    unsigned long ip_addr[4];
+    long ip_addr[4];
     int i, quads;
-    unsigned long bits;
+    long bits;
 
     /* if the address is given with an explicit netmask, use that */
     /* Due to a deficiency in ap_inet_addr(), it is impossible to parse */
@@ -900,11 +900,16 @@
 	if (!isdigit(*addr))
 	    return 0;		/* no digit at start of quad */
 
-	ip_addr[quads] = strtoul(addr, &tmp, 0);
+	ip_addr[quads] = strtol(addr, &tmp, 0);
 
 	if (tmp == addr)	/* expected a digit, found something else */
 	    return 0;
 
+	if (ip_addr[quads] < 0 || ip_addr[quads] > 255) {
+	    /* invalid octet */
+	    return 0;
+	}
+
 	addr = tmp;
 
 	if (*addr == '.' && quads != 3)
@@ -919,14 +924,14 @@
 
 	++addr;
 
-	bits = strtoul(addr, &tmp, 0);
+	bits = strtol(addr, &tmp, 0);
 
 	if (tmp == addr)	/* expected a digit, found something else */
 	    return 0;
 
 	addr = tmp;
 
-	if (bits > 32)		/* netmask must be between 0 and 32 */
+	if (bits < 0 || bits > 32)	/* netmask must be between 0 and 32 */
 	    return 0;
 
     }


Mime
View raw message