diff --git a/ChangeLog b/ChangeLog index b329e0c..52fb996 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,7 @@ -Version NEXT +Version 2.8.1b18 - 24 Nov 24 2003 + This is MINIMUM REQUIRED VERSION for applicatins which are using + javafsp library, only download machine atm. javafsp library will + be released shortly as separate package. PROTOCOL updated. Made rules about breaking directory header on packet boundary more clear. Previous text was from fspd code comment and was bad. @@ -10,19 +13,19 @@ Version NEXT in PROTOCOL support for MIN_DELAY, MAX_DELAY and DEFAULT_DELAY in source path parsing moved to separate file server/path.c - new test tool parsecheck + new test tool parsecheck for testing server path parser reworked parse path: separate error messages for high bit chars, control chars - do not segfault when parsing password protected files. Looks like - nobody used password protected files for a long time. This means - that in future version of FSP I can change protocol definition - without worry about breaking anything - path with trailing / or starting / is now parsed correctly + MAJOR BUGFIX: path with trailing / or starting / is now parsed correctly 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. + parsecheck turned into test suite with hard coded test results + parsecheck added to 'make check' + support for multiple \n in filename - in future there will be + used for symlinks. Version 2.8.1b17 -- 17 Nov 2003 Allow filenames with spaces inside diff --git a/TODO b/TODO index 75c947a..036e0c9 100644 --- a/TODO +++ b/TODO @@ -13,8 +13,6 @@ password change command TESTING NEEDED: Write a simple FSP protocol testing tool Write a test suite using testing tool -test if ending slashes do not confuse directory engine -test for /../ root escapes test for remote buffer overflows Test new command rename /when implemented/ Test if >2GB files but <4GB works correctly with and without --disable-largefile @@ -89,9 +87,9 @@ separate manpage for 7 fsp (protocol definition) == write FSP RFC libraries and support for FSP protocol ====================================== +DONE: FSP library for Java new small,light fsplib for C. -FSP plugin do Netscape/MSIE -FSP library for Java -Transfer HTTP over fsp transport FSP backend for APT +FSP plugin do Netscape/MSIE +Transfer HTTP over fsp transport FSP support to lftp,wget,curl diff --git a/server/path.c b/server/path.c index 8d05e59..aa8eef2 100644 --- a/server/path.c +++ b/server/path.c @@ -37,6 +37,7 @@ const char *parse_path PROTO3(char *, fullp, unsigned int, len, PPATH *, pp) { char *s; + char *p; int state; if(len < 1) return("Path must have non-zero length"); @@ -46,13 +47,19 @@ const char *parse_path PROTO3(char *, fullp, unsigned int, len, PPATH *, pp) pp->d_len = 0; - for(s = pp->fullp = pp->f_ptr = pp->d_ptr = fullp, state = 0; *s; s++) + for( + s = pp->fullp = pp->f_ptr = pp->d_ptr = fullp, state = 0; + *s; + s++ + ) { if(*s == '\n') { - pp->passwd = s+1; + p=strrchr(pp->fullp,'\n'); + pp->passwd = p+1; + *p = '\0'; *s = '\0'; - if(dbug) fprintf(stderr,"parse_path: found password field %s\n", s+1); + if(dbug) fprintf(stderr,"parse_path: found password field %s\n", p+1); break; } else diff --git a/tests/Makefile.am b/tests/Makefile.am index 2acafbf..2bd5f6e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -4,4 +4,4 @@ extra_DIST=mklargefile.py cachecheck_SOURCES=../server/fifocache.c cachecheck.c parsecheck_SOURCES=parsecheck.c ../server/path.c - +TESTS=parsecheck diff --git a/tests/parsecheck.c b/tests/parsecheck.c index c59b373..dce361d 100644 --- a/tests/parsecheck.c +++ b/tests/parsecheck.c @@ -9,11 +9,26 @@ #endif #include "my-string.h" -int dbug=0; +int dbug=1; -const char *testcases[]={ "", ".","filename","/filename","//filename","//dirname/filename","//dirname//filename","dirname//dir3name//","filename\npasswd", - "file/.dir","directory.ext/filename.","/", +const char *testcases[]={ + "", ".","/", + "filename","/filename","//filename", + "dirname/filename","//dirname/filename","//dirname//filename", + "dir1name/dir2name/","//dir1name//dir2name//", + "filename\npasswd","filename\nsymlink\npasswd", + "file/.dir","../updir","file/../dir", NULL}; +PPATH testresults[]={ + {".",".",1,".",1,NULL}, {NULL}, {".",".",1,".",1,NULL}, + {"filename","filename",8,".",1,NULL} , {"filename","filename",8,".",1,NULL} , {"filename","filename",8,".",1,NULL}, + {"dirname/filename","filename",8,"dirname",7,NULL} , {"dirname/filename","filename",8,"dirname",7,NULL} , {"dirname//filename","filename",8,"dirname",7,NULL}, + {"dir1name/dir2name/",".",1,"dir1name/dir2name",17}, {"dir1name//dir2name//",".",1,"dir1name//dir2name",18}, + {"filename","filename",8,".",1,"passwd"}, {"filename","filename",8,".",1,"passwd"}, + {NULL},{NULL},{NULL}, + + +}; static void print_path(PPATH *pp) { @@ -29,8 +44,27 @@ static void print_path(PPATH *pp) printf("passwd: %s",pp->passwd); } -static void runtestcase(void) +/* returns: 0 okay, 1 different */ + +static int compareresults(PPATH *p1,PPATH *p2) { + if(p1->fullp==NULL && p2->fullp==NULL) return 0; + if(p1->fullp==NULL || p2->fullp==NULL) return -1; + if(strcmp(p1->fullp,p2->fullp)) return -1; + if(p1->f_len!=p2->f_len) return -1; + if(strcmp(p1->f_ptr,p2->f_ptr)) return -1; + if(p1->d_len!=p2->d_len) return -1; + if(strncmp(p1->d_ptr,p2->d_ptr,p1->d_len)) return -1; + if(p1->passwd==NULL && p2->passwd==NULL) + return 0; + if(p1->passwd==NULL || p2->passwd==NULL) return -1; + if(strcmp(p1->passwd,p2->passwd)) return -1; + return 0; +} + +static int runtestcase(void) +{ + int rc=0; int i=0; PPATH pp; const char *err; @@ -39,24 +73,33 @@ static void runtestcase(void) for(;testcases[i];i++) { test=strdup(testcases[i]); + pp.fullp=NULL; err=parse_path(test,strlen(test)+1,&pp); printf("parsing: '%s'",test); if(err) { - printf(" err: %s\n",err); - free(test); - continue; + printf(" parse err: '%s'. ",err); + pp.fullp=NULL; } else - printf(" okay.\n"); - printf(" "); - print_path(&pp); - printf("\n"); + printf(" parsed okay. "); + if(compareresults(&pp,&testresults[i])) + { + printf("!!!TEST FAILED!!!\a\n"); + rc=1; + } else + printf(" Test passed.\n"); + if(!err) + { + printf(" "); + print_path(&pp); + printf("\n"); + } free(test); } + return rc; } int main(int argc,const char *argv[]) { - runtestcase(); - return 0; + return runtestcase(); }