diff options
| author | apnadkarni <apnmbx-wits@yahoo.com> | 2023-09-15 16:39:57 (GMT) |
|---|---|---|
| committer | apnadkarni <apnmbx-wits@yahoo.com> | 2023-09-15 16:39:57 (GMT) |
| commit | afd38a94a38c9878adce8cf29c863fbe28e9e72e (patch) | |
| tree | 7da69068d2c92c7454edaa52655f658f514da600 | |
| parent | c4b43f3f1979dfca2d5303061b6431246ab399e4 (diff) | |
| download | tcl-afd38a94a38c9878adce8cf29c863fbe28e9e72e.zip tcl-afd38a94a38c9878adce8cf29c863fbe28e9e72e.tar.gz tcl-afd38a94a38c9878adce8cf29c863fbe28e9e72e.tar.bz2 | |
Add false positive tests for CRC checking
| -rw-r--r-- | generic/tclZipfs.c | 4 | ||||
| -rw-r--r-- | tests/zipfs.test | 14 |
2 files changed, 16 insertions, 2 deletions
diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c index 2297e79..248732b 100644 --- a/generic/tclZipfs.c +++ b/generic/tclZipfs.c @@ -225,14 +225,14 @@ typedef struct ZipEntry { int numCompressedBytes; /* Compressed size of the virtual file. -1 for zip64 */ int compressMethod; /* Compress method */ - int isDirectory; /* Set to 1 if directory, or -1 if root */ + int isDirectory; /* 0 if file, 1 if directory, -1 if root */ int depth; /* Number of slashes in path. */ int crc32; /* CRC-32 as stored in ZIP */ int timestamp; /* Modification time */ int isEncrypted; /* True if data is encrypted */ int flags; #define ZE_F_CRC_COMPARED 0x1 /* If 1, the CRC has been compared. */ -#define ZE_F_CRC_CORRECT 0x2 /* Only meaningful if ZE_F_CRC_CHECKED is 1 */ +#define ZE_F_CRC_CORRECT 0x2 /* Only meaningful if ZE_F_CRC_COMPARED is 1 */ unsigned char *data; /* File data if written */ struct ZipEntry *next; /* Next file in the same archive */ struct ZipEntry *tnext; /* Next top-level dir in archive */ diff --git a/tests/zipfs.test b/tests/zipfs.test index 6c0870e..11fd306 100644 --- a/tests/zipfs.test +++ b/tests/zipfs.test @@ -40,6 +40,8 @@ if {![string match ${ziproot}* $tcl_library]} { ### set tclzip [file join $CWD libtcl[info patchlevel].zip] testConstraint zipfslib [file isfile $tclzip] + puts C:[testConstraint zipfslib],$tclzip,$tcl_library + parray ::env TCL* if {[testConstraint zipfslib]} { zipfs mount $tclzip /lib/tcl set ::tcl_library ${ziproot}lib/tcl/tcl_library @@ -1007,6 +1009,18 @@ namespace eval test_ns_zipfs { testcrc local incons-local-crc.zip a "invalid CRC" testcrc store-crc broken.zip storedcrcerror "invalid CRC" testcrc deflate-crc broken.zip deflatecrcerror "invalid CRC" + test zipfs-crc-false-positives { + Verify no false positives in CRC checking + } -constraints zipfslib -body { + # Just loop ensuring no crc failures + foreach f [zipfs list] { + if {[file isfile $f]} { + close [open $f] + incr count + } + } + expr {$count > 0} + } -result 1 # # file stat |
