Return-Path: Delivered-To: apmail-apr-commits-archive@www.apache.org Received: (qmail 73843 invoked from network); 24 Jul 2006 05:54:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 24 Jul 2006 05:54:28 -0000 Received: (qmail 32329 invoked by uid 500); 24 Jul 2006 05:54:16 -0000 Delivered-To: apmail-apr-commits-archive@apr.apache.org Received: (qmail 32257 invoked by uid 500); 24 Jul 2006 05:54:16 -0000 Mailing-List: contact commits-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: Reply-To: dev@apr.apache.org List-Id: Delivered-To: mailing list commits@apr.apache.org Received: (qmail 32207 invoked by uid 99); 24 Jul 2006 05:54:16 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 23 Jul 2006 22:54:15 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 23 Jul 2006 22:54:15 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 042741A981D; Sun, 23 Jul 2006 22:53:55 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r424916 - /apr/apr/branches/1.2.x/file_io/win32/filepath.c Date: Mon, 24 Jul 2006 05:53:54 -0000 To: commits@apr.apache.org From: wrowe@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060724055355.042741A981D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: wrowe Date: Sun Jul 23 22:53:54 2006 New Revision: 424916 URL: http://svn.apache.org/viewvc?rev=424916&view=rev Log: Solve svn issue 1869, avoid replacing previous ../ segments when multiple ../../.. patterns are present. This patch also normalizes the .. path seperators to use the same rules as normal paths, that is, if it's NATIVE use '\' (previous behavior), and (new behavior) if TRUENAME not NATIVE, use '/', otherwise the given slash. Adds no trailing slash if none was present on input. Solved with hints from Lieven Govaerts . Resolves test fail identified by test/testnames.c commit 424831 Backports: 424915 Modified: apr/apr/branches/1.2.x/file_io/win32/filepath.c Modified: apr/apr/branches/1.2.x/file_io/win32/filepath.c URL: http://svn.apache.org/viewvc/apr/apr/branches/1.2.x/file_io/win32/filepath.c?rev=424916&r1=424915&r2=424916&view=diff ============================================================================== --- apr/apr/branches/1.2.x/file_io/win32/filepath.c (original) +++ apr/apr/branches/1.2.x/file_io/win32/filepath.c Sun Jul 23 22:53:54 2006 @@ -677,16 +677,22 @@ /* Otherwise this is simply a noop, above root is root. */ } - else if (pathlen == 0 || - (pathlen >= 3 && (pathlen == 3 - || path[pathlen - 4] == ':') - && path[pathlen - 3] == '.' - && path[pathlen - 2] == '.' - && (path[pathlen - 1] == '/' - || path[pathlen - 1] == '\\'))) + else if (pathlen == 0 + || (pathlen >= 3 + && (pathlen == 3 + || path[pathlen - 4] == ':' + || path[pathlen - 4] == '/' + || path[pathlen - 4] == '\\') + && path[pathlen - 3] == '.' + && path[pathlen - 2] == '.' + && (path[pathlen - 1] == '/' + || path[pathlen - 1] == '\\'))) { - /* Path is already backpathed or empty, if the - * APR_FILEPATH_SECUREROOTTEST.was given die now. + /* Verified path is empty, exactly "..[/\]", or ends + * in "[:/\]..[/\]" - these patterns we will not back + * over since they aren't 'prior segements'. + * + * If APR_FILEPATH_SECUREROOTTEST.was given, die now. */ if (flags & APR_FILEPATH_SECUREROOTTEST) return APR_EABOVEROOT; @@ -695,9 +701,13 @@ */ if (pathlen + 3 >= sizeof(path)) return APR_ENAMETOOLONG; - memcpy(path + pathlen, ((flags & APR_FILEPATH_NATIVE) - ? "..\\" : "../"), 3); - pathlen += 3; + path[pathlen++] = '.'; + path[pathlen++] = '.'; + if (addpath[segend]) { + path[pathlen++] = ((flags & APR_FILEPATH_NATIVE) + ? '\\' : ((flags & APR_FILEPATH_TRUENAME) + ? '/' : addpath[segend])); + } /* The 'root' part of this path now includes the ../ path, * because that backpath will not be parsed by the truename * code below.