From f2feaf1ba64c74c230a95a63c42b1b78ba9965ce Mon Sep 17 00:00:00 2001 From: hsn <> Date: Sat, 22 Nov 2003 17:18:02 +0000 Subject: [PATCH] fixed some path parsing problems --- .cvsignore | 1 + ChangeLog | 2 ++ server/path.c | 16 ++++++++-------- tests/parsecheck.c | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.cvsignore b/.cvsignore index 7dff072..578008b 100644 --- a/.cvsignore +++ b/.cvsignore @@ -7,6 +7,7 @@ config.cache config.guess config.log config.status +configure.lineno config.sub configure depcomp diff --git a/ChangeLog b/ChangeLog index 7bb08f7..b329e0c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,6 +21,8 @@ Version NEXT pathes with dot after slash are now detected at parse level (side effect of prev. fix) tests moved from server/ into tests/ directory + removed special test case for root directory in path.c -> use more + general alg. instead. This fixed "/" dir. Version 2.8.1b17 -- 17 Nov 2003 Allow filenames with spaces inside diff --git a/server/path.c b/server/path.c index 8bee188..8d05e59 100644 --- a/server/path.c +++ b/server/path.c @@ -40,18 +40,11 @@ const char *parse_path PROTO3(char *, fullp, unsigned int, len, PPATH *, pp) int state; if(len < 1) return("Path must have non-zero length"); - if(fullp[len-1]) return("Path not null terminated"); + if(fullp[len-1]) return("Path must be null terminated"); pp->passwd = NULL; /* default, no password */ pp->d_len = 0; - if(len == 1 && fullp[0] == 0) - { - /* null path --> root */ - pp->fullp = pp->f_ptr = pp->d_ptr = "."; - pp->f_len = pp->d_len = 1; - return(NULLP); - } for(s = pp->fullp = pp->f_ptr = pp->d_ptr = fullp, state = 0; *s; s++) { @@ -114,6 +107,13 @@ const char *parse_path PROTO3(char *, fullp, unsigned int, len, PPATH *, pp) pp->f_ptr = "."; pp->f_len = 1; } + + /* turn empty fullp into "." */ + if(pp->fullp[0] == 0) + { + /* null path --> root */ + pp->fullp = "."; + } return(NULLP); } diff --git a/tests/parsecheck.c b/tests/parsecheck.c index 3326928..c59b373 100644 --- a/tests/parsecheck.c +++ b/tests/parsecheck.c @@ -12,7 +12,7 @@ int dbug=0; const char *testcases[]={ "", ".","filename","/filename","//filename","//dirname/filename","//dirname//filename","dirname//dir3name//","filename\npasswd", - "file/.dir","directory.ext/filename.", + "file/.dir","directory.ext/filename.","/", NULL}; static void print_path(PPATH *pp)