Skip to content

Commit d0ce57c

Browse files
committed
Treat Windows style paths in daemon_avoid_alias.
Without this increased portability, http-backend always dies with code 500 because it mistakes a path beginning with a drive prefix as a relative path. Signed-off-by: Johannes Sixt <j6t@kdbg.org>
1 parent 16bd9f2 commit d0ce57c

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

path.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,17 +1436,19 @@ int daemon_avoid_alias(const char *p)
14361436
* be true as long as dots continue after that without intervening
14371437
* non-dot character.
14381438
*/
1439-
if (!p || (*p != '/' && *p != '~'))
1439+
if (!p || (!is_absolute_path(p) && *p != '~'))
14401440
return -1;
14411441
sl = 1; ndot = 0;
1442+
if (has_dos_drive_prefix(p))
1443+
p += 2;
14421444
p++;
14431445

14441446
while (1) {
14451447
char ch = *p++;
14461448
if (sl) {
14471449
if (ch == '.')
14481450
ndot++;
1449-
else if (ch == '/') {
1451+
else if (is_dir_sep(ch)) {
14501452
if (ndot < 3)
14511453
/* reject //, /./ and /../ */
14521454
return -1;
@@ -1463,7 +1465,7 @@ int daemon_avoid_alias(const char *p)
14631465
}
14641466
else if (ch == 0)
14651467
return 0;
1466-
else if (ch == '/') {
1468+
else if (is_dir_sep(ch)) {
14671469
sl = 1;
14681470
ndot = 0;
14691471
}

0 commit comments

Comments
 (0)