httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <dgau...@arctic.org>
Subject [PATCH] 1.3: "DoS" attack
Date Tue, 30 Dec 1997 18:15:34 GMT
Just say no to O(n^2). 

Dean

Index: main/util.c
===================================================================
RCS file: /export/home/cvs/apachen/src/main/util.c,v
retrieving revision 1.78
diff -u -r1.78 util.c
--- util.c	1997/12/19 14:30:12	1.78
+++ util.c	1997/12/30 18:07:02
@@ -365,14 +365,20 @@
 
 API_EXPORT(void) no2slash(char *name)
 {
-    register int x, y;
+    char *d, *s;
 
-    for (x = 0; name[x];)
-	if (x && (name[x - 1] == '/') && (name[x] == '/'))
-	    for (y = x + 1; name[y - 1]; y++)
-		name[y - 1] = name[y];
-	else
-	    x++;
+    s = d = name;
+    while (*s) {
+	if ((*d++ = *s) == '/') {
+	    do {
+		++s;
+	    } while (*s == '/');
+	}
+	else {
+	    ++s;
+	}
+    }
+    *d = '\0';
 }
 
 



Mime
View raw message