From: Brian Pane Date: Mon, 3 Dec 2001 00:49:28 +0000 (+0000) Subject: Optimization for ap_getparents: skip past all the leading X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4646dda1cc603d1150c8dc2a979bd1084fc8dc40;p=apache Optimization for ap_getparents: skip past all the leading characters of the path that aren't '.' rather than copying those bytes onto themselves git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@92292 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/util.c b/server/util.c index 71b42f8b66..beda6b4390 100644 --- a/server/util.c +++ b/server/util.c @@ -476,12 +476,15 @@ AP_DECLARE(char *) ap_pregsub(apr_pool_t *p, const char *input, const char *sour */ AP_DECLARE(void) ap_getparents(char *name) { - int l, w; + char *next; + int l, w, first_dot; /* Four paseses, as per RFC 1808 */ /* a) remove ./ path segments */ - - for (l = 0, w = 0; name[l] != '\0';) { + for (next = name; *next && (*next != '.'); next++) { + } + l = w = first_dot = next - name; + while (name[l] != '\0') { if (name[l] == '.' && name[l + 1] == '/' && (l == 0 || name[l - 1] == '/')) l += 2; else @@ -496,7 +499,7 @@ AP_DECLARE(void) ap_getparents(char *name) name[w] = '\0'; /* c) remove all xx/../ segments. (including leading ../ and /../) */ - l = 0; + l = first_dot; while (name[l] != '\0') { if (name[l] == '.' && name[l + 1] == '.' && name[l + 2] == '/' &&