You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Dean Gaudet <dg...@arctic.org> on 1997/11/03 05:23:41 UTC
[PATCH] PR#1248, 1328: mod_access problems
I messed up the byte ordering in the new mod_access code. This patch
fixes it, and improves the error detection. The submitter of 1248 reports
success, I haven't heard back from 1328.
Dean
Index: mod_access.c
===================================================================
RCS file: /export/home/cvs/apachen/src/modules/standard/mod_access.c,v
retrieving revision 1.27
diff -u -r1.27 mod_access.c
--- mod_access.c 1997/10/22 20:30:11 1.27
+++ mod_access.c 1997/11/03 04:20:17
@@ -204,12 +204,14 @@
/* legacy syntax for ip addrs: a.b.c. ==> a.b.c.0/24 for example */
int shift;
char *t;
+ int octet;
a->type = T_IP;
/* parse components */
s = where;
a->x.ip.net = 0;
- shift = 0;
+ a->x.ip.mask = 0;
+ shift = 24;
while (*s) {
t = s;
if (!isdigit(*t)) {
@@ -226,11 +228,21 @@
a->type = T_FAIL;
return "invalid ip address";
}
- a->x.ip.net |= atoi(s) << shift;
+ if (shift < 0) {
+ return "invalid ip address, only 4 octets allowed";
+ }
+ octet = atoi(s);
+ if (octet < 0 || octet > 255) {
+ a->type = T_FAIL;
+ return "each octet must be between 0 and 255 inclusive";
+ }
+ a->x.ip.net |= octet << shift;
a->x.ip.mask |= 0xFFUL << shift;
- shift += 8;
s = t;
+ shift -= 8;
}
+ a->x.ip.net = ntohl(a->x.ip.net);
+ a->x.ip.mask = ntohl(a->x.ip.mask);
}
else {
a->type = T_HOST;