dgaudet 97/12/30 11:03:19
Modified: . STATUS src CHANGES src/main util.c Log: Fix O(n^2) problem with no2slash() Reviewed by: Marc Slemko, Brian Behlendorf Revision Changes Path 1.42 +1 -4 apachen/STATUS Index: STATUS =================================================================== RCS file: /export/home/cvs/apachen/STATUS,v retrieving revision 1.41 retrieving revision 1.42 diff -u -r1.41 -r1.42 --- STATUS 1997/12/30 18:43:05 1.41 +++ STATUS 1997/12/30 19:03:14 1.42 @@ -61,12 +61,9 @@ (take 2) * Ken's [PATCH] for PR#1195 (" in realm names) * Jim's [PATCH] ap_cpystrn() function (replace strncpy) Take II + * Dean's [PATCH] 1.3: "DoS" attack Available Patches: - - * Dean's [PATCH] 1.3: "DoS" attack - <[EMAIL PROTECTED]> - Status: Dean +1 * [PATCH] mod_digest/1599: proxy authentication using the digest auth scheme never succeeds (fwd) 1.553 +3 -0 apachen/src/CHANGES Index: CHANGES =================================================================== RCS file: /export/home/cvs/apachen/src/CHANGES,v retrieving revision 1.552 retrieving revision 1.553 diff -u -r1.552 -r1.553 --- CHANGES 1997/12/30 15:10:41 1.552 +++ CHANGES 1997/12/30 19:03:16 1.553 @@ -1,5 +1,8 @@ Changes with Apache 1.3b4 + *) no2slash() was O(n^2) in the length of the input. Make it O(n). + [Dean Gaudet] + *) migration from strncpy() to our "enhanced" version called ap_cpystrn() for performance and functionality reasons. Located in libap.a. [Jim Jagielski] 1.80 +13 -7 apachen/src/main/util.c Index: util.c =================================================================== RCS file: /export/home/cvs/apachen/src/main/util.c,v retrieving revision 1.79 retrieving revision 1.80 diff -u -r1.79 -r1.80 --- util.c 1997/12/30 15:10:49 1.79 +++ util.c 1997/12/30 19:03:18 1.80 @@ -366,14 +366,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'; }