Skip to content

File modes for DOS archives not correctly mapped to unix modes #737

@JellyWX

Description

@JellyWX

Describe the bug

9e9badde appears to have broken permissions on extracted DOS zips. I noticed this when trying to extract Bandcamp downloads (not attached due to copyright note) on COSMIC, which is compiled against zip 7.2.0

I'm still investigating a bit, but seems to be related to #471, #470

The COSMIC issue pop-os/cosmic-epoch#2525 looks related, but pre-dates this.

To Reproduce

Take this file: unix_mode_0x081A4000.zip

Calling unix_mode() against the file in this zip returns 2074. Prior to the linked commit, this would return 33204.

use std::io::Cursor;
use zip::ZipArchive;

#[test]
fn unix_mode_dos() {
    let data = include_bytes!("data/unix_mode_0x081A4000.zip");
    let mut archive = ZipArchive::new(Cursor::new(data)).unwrap();
    for i in 0..archive.len() {
        let file = archive.by_index(i).unwrap();
        assert_eq!(
            file.unix_mode(),
            Some(33204),
            "file {:?} has unix_mode {:?}",
            file.name(),
            file.unix_mode()
        );
    }
}

The result in COSMIC is files with permission set as ---S-wx-w-

jude@xxx:~/Downloads/unix_mode_0x081A4000$ ls -lah
total 12K
drwxrwxr-x 2 jude jude 4.0K Mar 20 09:12 .
drwxr-xr-x 8 jude jude 4.0K Mar 20 09:12 ..
---S-wx-w- 1 jude jude   11 Jan  1  1980 test_file.txt

Desktop

  • OS: Pop!_OS 24.04

I've also tested this with the latest version of the library. The commit above was picked out with a bisection. I've confirmed that compiling COSMIC files with zip=7.1.0 resolves this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions