From: <no...@tc...> - 2025-03-06 16:48:17
|
Automated mail by fx, on behalf of no...@tc... Ticket Change [6d407ad805b12e7d5d0414c375626744901d273b23989a3bde9b009684698c64] [zipfile::decode::unzip permissions bug with some zips] By umlaeute For Tcllib On 2025-03-06T16:40:22.060 Details https://core.tcl-lang.org/tcllib/tinfo?name=6d407ad805b12e7d5d0414c375626744901d273b23989a3bde9b009684698c64 Ticket https://core.tcl-lang.org/tcllib/tktview/a0cbdc7e6f4a977e4c24b5a1a5c0f578c334958d Changed Fields assignee: nobody closer: nobody comment: Some ZIP-files generated on Windows cannot be properly extracted: the extracted files end up with a permission of `0o000` One such ZIP-file can be downloaded via https://github.com/user-attachments/files/19111907/iem_vanilla.zip `zipinfo -v` tells me something like this: ``` Central directory entry #1: --------------------------- iem_vanilla/0.INTRO.txt offset of local header from start of archive: 0 (0000000000000000h) bytes file system or operating system of origin: MS-DOS, OS/2 or NT FAT version of encoding software: 2.0 minimum file system compatibility required: MS-DOS, OS/2 or NT FAT minimum software version required to extract: 2.0 compression method: deflated compression sub-type (deflation): normal file security status: not encrypted extended local header: no file last modified on (DOS date/time): 2020 Oct 30 15:42:26 32-bit CRC value (hex): bda8cbfe compressed size: 1861 bytes uncompressed size: 4899 bytes length of filename: 23 characters length of extra field: 0 bytes length of file comment: 0 characters disk number on which file begins: disk 1 apparent file type: text non-MSDOS external file attributes: 000000 hex MS-DOS file attributes (20 hex): arc There is no file comment. ``` The problem is apparently, that the `efattr` field for the file is something like `32`, which tcllib takes as an invitation to change the permissions, but then calculates the permissions as `0`. Cf this code for [::zipfile::decode::CopyFile](https://core.tcl-lang.org/tcllib/file?ci =tip&name=modules/zip/decode.tcl&ln=220-234): ``` if { ($::tcl_platform(platform) ne "windows") && ($fd(efattr) != 0) } { file attributes $dst -permissions \\ [string map {0 --- 1 --x 2 -w- 3 -wx 4 r-- 5 r-x 6 rw- 7 rwx} \\ [format %03o [expr {($fd(efattr) >> 16) & 0x1ff}]]] } ``` (obviously, `(32>>16)&0x1ff` evaluates to `0`. foundin: 2.0 is_private: 0 login: umlaeute priority: 5 Medium private_contact: 25d17d5d6504beca5be732fc23fc1776440fca23 resolution: None severity: Minor status: Open submitter: umlaeute subsystem: zip title: zipfile::decode::unzip permissions bug with some zips type: Bug ------------------------------------------------------------ See Tcl/Tk development @ http://core.tcl-lang.org/ ------------------------------------------------------------ |