diff options
author | apnadkarni <apnmbx-wits@yahoo.com> | 2023-09-18 16:59:09 (GMT) |
---|---|---|
committer | apnadkarni <apnmbx-wits@yahoo.com> | 2023-09-18 16:59:09 (GMT) |
commit | 8966a8fda6956c4aff4b07d5c154b9816f14f947 (patch) | |
tree | 68654662f117cc474bfdaa1b8b271185b344c331 /generic | |
parent | a55cf1edad4209ab3de602ff4c4a93abb25fce1c (diff) | |
parent | 1e8ecbdd537a4d9c8295c215277a3f381efae74c (diff) | |
download | tcl-8966a8fda6956c4aff4b07d5c154b9816f14f947.zip tcl-8966a8fda6956c4aff4b07d5c154b9816f14f947.tar.gz tcl-8966a8fda6956c4aff4b07d5c154b9816f14f947.tar.bz2 |
Bug [d056ee6d30] - zipfs list returns invalid paths
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclZipfs.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c index a38bc5b..42d9899 100644 --- a/generic/tclZipfs.c +++ b/generic/tclZipfs.c @@ -84,6 +84,7 @@ static const z_crc_t* crc32tab; */ #define ZIPFS_VOLUME "//zipfs:/" +#define ZIPFS_ROOTDIR_DEPTH 3 /* Number of / in root mount */ #define ZIPFS_VOLUME_LEN 9 #define ZIPFS_APP_MOUNT ZIPFS_VOLUME "app" #define ZIPFS_ZIP_MOUNT ZIPFS_VOLUME "lib/tcl" @@ -1728,6 +1729,7 @@ ZipFSCatalogFilesystem( Tcl_SetHashValue(hPtr, z); z->depth = CountSlashes(mountPoint); + assert(z->depth >= ZIPFS_ROOTDIR_DEPTH); z->zipFilePtr = zf; z->isDirectory = (zf->baseOffset == 0) ? 1 : -1; /* root marker */ z->offset = zf->baseOffset; @@ -1816,6 +1818,7 @@ ZipFSCatalogFilesystem( fullpath = CanonicalPath(mountPoint, path, &fpBuf, 1); z = AllocateZipEntry(); z->depth = CountSlashes(fullpath); + assert(z->depth >= ZIPFS_ROOTDIR_DEPTH); z->zipFilePtr = zf; z->isDirectory = isdir; z->isEncrypted = @@ -1853,7 +1856,7 @@ ZipFSCatalogFilesystem( z->name = (char *) Tcl_GetHashKey(&ZipFS.fileHash, hPtr); z->next = zf->entries; zf->entries = z; - if (isdir && (mountPoint[0] == '\0') && (z->depth == 1)) { + if (isdir && (mountPoint[0] == '\0') && (z->depth == ZIPFS_ROOTDIR_DEPTH)) { z->tnext = zf->topEnts; zf->topEnts = z; } @@ -1863,7 +1866,7 @@ ZipFSCatalogFilesystem( * containing directory nodes. */ - if (!z->isDirectory && (z->depth > 1)) { + if (!z->isDirectory && (z->depth > ZIPFS_ROOTDIR_DEPTH)) { char *dir, *endPtr; ZipEntry *zd; @@ -1884,6 +1887,7 @@ ZipFSCatalogFilesystem( zd = AllocateZipEntry(); zd->depth = CountSlashes(dir); + assert(zd->depth > ZIPFS_ROOTDIR_DEPTH); zd->zipFilePtr = zf; zd->isDirectory = 1; zd->offset = z->offset; @@ -1893,7 +1897,7 @@ ZipFSCatalogFilesystem( zd->name = (char *) Tcl_GetHashKey(&ZipFS.fileHash, hPtr); zd->next = zf->entries; zf->entries = zd; - if ((mountPoint[0] == '\0') && (zd->depth == 1)) { + if ((mountPoint[0] == '\0') && (zd->depth == ZIPFS_ROOTDIR_DEPTH)) { zd->tnext = zf->topEnts; zf->topEnts = zd; } |