From 68e4d107045a5a01945deb6535bd1b09c1e8d30d Mon Sep 17 00:00:00 2001 From: Vince Darley Date: Sun, 2 Dec 2001 23:07:31 +0000 Subject: [PATCH] unix fix --- ChangeLog | 5 +++++ generic/vfs.c | 33 +++++++++++++++++++++++---------- win/makefile.vc | 2 +- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 00e60c7..4c2c825 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-12-02 Vince Darley + * generic/vfs.c: minor code cleanup and simplification. Fix + to problem with absolute paths on unix systems introduced in + recent changes. + 2001-11-21 Vince Darley * generic/vfs.c: added more comments to the code, and made mount point checking faster and simpler (we no longer diff --git a/generic/vfs.c b/generic/vfs.c index 066e547..ecc69d8 100644 --- a/generic/vfs.c +++ b/generic/vfs.c @@ -807,8 +807,6 @@ VfsPathInFilesystem(Tcl_Obj *pathPtr, ClientData *clientDataPtr) { normed = Tcl_GetStringFromObj(normedObj, &len); splitPosition = len; - if (len == 0) return -1; - /* * Find the most specific mount point for this path. * Mount points are specified by unique strings, so @@ -820,6 +818,18 @@ VfsPathInFilesystem(Tcl_Obj *pathPtr, ClientData *clientDataPtr) { * checking for valid mount points at each separator. */ while (1) { + /* + * We need this test here both for an empty string being + * passed in above, and so that if we are testing a unix + * absolute path /foo/bar we will come around the loop + * with splitPosition at 0 for the last test, and we + * must return then. + */ + if (splitPosition == 0) { + return -1; + } + + /* Is the path up to 'splitPosition' a valid moint point? */ interpCmd = Vfs_FindMount(normedObj, splitPosition); if (interpCmd != NULL) break; @@ -836,15 +846,18 @@ VfsPathInFilesystem(Tcl_Obj *pathPtr, ClientData *clientDataPtr) { /* * We now know that normed[splitPosition] is a separator. * However, we might have mounted a root filesystem with a - * strange name (for example 'ftp://') + * name (for example 'ftp://') which actually includes a + * separator. Therefore we test whether the path with + * a separator is a mount point. + * + * Since we must have decremented splitPosition at least once + * already (above) 'splitPosition+1 <= len' so this won't + * access invalid memory. */ - if (splitPosition != len) { - interpCmd = Vfs_FindMount(normedObj, splitPosition+1); - - if (interpCmd != NULL) { - splitPosition++; - break; - } + interpCmd = Vfs_FindMount(normedObj, splitPosition+1); + if (interpCmd != NULL) { + splitPosition++; + break; } } diff --git a/win/makefile.vc b/win/makefile.vc index 49c2e58..315911d 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -13,7 +13,7 @@ VFS_VERSION = 1.0 DLL_VERSION = 10 # comment the following line to compile with symbols -NODEBUG=1 +NODEBUG=0 !IF "$(NODEBUG)" == "1" DEBUGDEFINES = -- 2.23.0