Skip to content

Commit 6a60357

Browse files
committed
Fix canonicalize_path so "../.." isn't stripped off and ignored.
1 parent 24ff62d commit 6a60357

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/port/path.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/port/path.c,v 1.51 2005/01/26 19:24:03 tgl Exp $
11+
* $PostgreSQL: pgsql/src/port/path.c,v 1.52 2005/08/11 03:53:25 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -284,7 +284,10 @@ canonicalize_path(char *path)
284284

285285
if (len > 2 && strcmp(path + len - 2, "/.") == 0)
286286
trim_directory(path);
287-
else if (len > 3 && strcmp(path + len - 3, "/..") == 0)
287+
/* We can only deal with "/usr/local/..", not "/usr/local/../.." */
288+
else if (len > 3 && strcmp(path + len - 3, "/..") == 0 &&
289+
(len != 5 || strcmp(path, "../..") != 0) &&
290+
(len < 6 || strcmp(path + len - 6, "/../..") != 0))
288291
{
289292
trim_directory(path);
290293
trim_directory(path); /* remove directory above */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy