summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorapnadkarni <apnmbx-wits@yahoo.com>2023-09-28 17:11:39 (GMT)
committerapnadkarni <apnmbx-wits@yahoo.com>2023-09-28 17:11:39 (GMT)
commit9fb03c8b99518f5210907247a9bdc5c397516012 (patch)
tree26ff9f87e465853c992613ce12bb63adce313ffe
parent1cebc18c7595887b559fc17235acc0315299c9eb (diff)
downloadtcl-9fb03c8b99518f5210907247a9bdc5c397516012.zip
tcl-9fb03c8b99518f5210907247a9bdc5c397516012.tar.gz
tcl-9fb03c8b99518f5210907247a9bdc5c397516012.tar.bz2
Progress on [6d2ef441cc]
-rw-r--r--generic/tclZipfs.c18
-rw-r--r--tests/zipfiles/test-password2.zipbin176 -> 478 bytes
-rw-r--r--tests/zipfs.test26
3 files changed, 21 insertions, 23 deletions
diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c
index 80bcdc3..7616ad3 100644
--- a/generic/tclZipfs.c
+++ b/generic/tclZipfs.c
@@ -4873,21 +4873,7 @@ InitWritableChannel(
unsigned char *zbuf = z->zipFilePtr->data + z->offset;
if (z->isEncrypted) {
- int len = z->zipFilePtr->passBuf[0] & 0xFF;
- char passBuf[260];
-
- for (i = 0; i < len; i++) {
- ch = z->zipFilePtr->passBuf[len - i];
- passBuf[i] = (ch & 0x0f) | pwrot[(ch >> 4) & 0x0f];
- }
- passBuf[i] = '\0';
- init_keys(passBuf, info->keys, crc32tab);
- memset(passBuf, 0, sizeof(passBuf));
- for (i = 0; i < 12; i++) {
- ch = info->ubuf[i];
- zdecode(info->keys, crc32tab, ch);
- }
- zbuf += i;
+ zbuf += 12;
}
if (z->compressMethod == ZIP_COMPMETH_DEFLATED) {
@@ -4911,7 +4897,7 @@ InitWritableChannel(
goto memoryError;
}
for (j = 0; j < stream.avail_in; j++) {
- ch = info->ubuf[j];
+ ch = zbuf[j];
cbuf[j] = zdecode(info->keys, crc32tab, ch);
}
stream.next_in = cbuf;
diff --git a/tests/zipfiles/test-password2.zip b/tests/zipfiles/test-password2.zip
index 82bb732..75a4d1c 100644
--- a/tests/zipfiles/test-password2.zip
+++ b/tests/zipfiles/test-password2.zip
Binary files differ
diff --git a/tests/zipfs.test b/tests/zipfs.test
index f979f57..e7f8de9 100644
--- a/tests/zipfs.test
+++ b/tests/zipfs.test
@@ -1246,7 +1246,7 @@ namespace eval test_ns_zipfs {
fconfigure $fd -translation binary
read $fd
}
- test zipfs-password-$id "zipfs write $id" -setup {
+ test zipfs-password-write-$id "zipfs write $id" -setup {
unset -nocomplain fd
if {$password ne ""} {
zipfs mount $zippath $defaultMountPoint $password
@@ -1261,12 +1261,24 @@ namespace eval test_ns_zipfs {
cleanup
} -body $body -result $result {*}$args
}
- testpasswordw write-w test-password.zip cipher.bin password w xyz
- testpasswordw write-badpass-w test-password.zip cipher.bin badpass w {invalid password} -returnCodes error
- testpasswordw write-w+ test-password.zip cipher.bin password w xyz
- testpasswordw write-badpass-w+ test-password.zip cipher.bin badpass w {invalid password} -returnCodes error
- testpasswordw write-a+ test-password.zip cipher.bin password a+ ciphertextxyz
- testpasswordw write-badpass-a+ test-password.zip cipher.bin badpass a+ {invalid password} -returnCodes error
+ # NOTE: test-password.zip is the DOS time based encryption header validity check (infozip style)
+ # test-password2.zip is the CRC based encryption header validity check (pkware style)
+ testpasswordw cipher-w-1 test-password.zip cipher.bin password w xyz
+ testpasswordw cipher-w-2 test-password2.zip cipher.bin password w xyz
+ testpasswordw cipher-deflate-w test-password2.zip cipher-deflate.bin password w xyz
+ testpasswordw cipher-badpass-w-1 test-password.zip cipher.bin badpass w {invalid password} -returnCodes error
+ testpasswordw cipher-badpass-w-2 test-password2.zip cipher.bin badpass w {invalid password} -returnCodes error
+ testpasswordw cipher-badpass-deflate-w test-password2.zip cipher-deflate.bin badpass w {invalid password} -returnCodes error
+
+ testpasswordw cipher-w+ test-password.zip cipher.bin password w xyz
+ testpasswordw cipher-deflate-w+ test-password2.zip cipher-deflate.bin password w xyz
+ testpasswordw cipher-badpass-w+ test-password.zip cipher.bin badpass w {invalid password} -returnCodes error
+ testpasswordw cipher-badpass-deflate-w+ test-password2.zip cipher-deflate.bin badpass w {invalid password} -returnCodes error
+
+ testpasswordw cipher-a+ test-password.zip cipher.bin password a+ ciphertextxyz
+ testpasswordw cipher-deflate-a+ test-password2.zip cipher-deflate.bin password a+ [lseq 100]xyz
+ testpasswordw cipher-badpass-a+ test-password.zip cipher.bin badpass a+ {invalid password} -returnCodes error
+ testpasswordw cipher-badpass-deflate-a+ test-password2.zip cipher-deflate.bin badpass a+ {invalid password} -returnCodes error
#
# CRC errors