mdsteele / rust-cab

Rust library for encoding/decoding Windows cabinet (.cab) files
MIT License
16 stars 9 forks source link

`rust-cab` fails to open most CAB files from Win98SE CD #29

Open nikitalita opened 9 months ago

nikitalita commented 9 months ago

https://archive.org/details/windows-98-se-isofile

Most of these fail to be opened, and the ones that fail all have the error "File entry folder index out of bounds".

Succeeded: 4, Failed: 73

The only 4 that succeeded are:

CATALOG3.CAB mini.cab chl99.cab WIN98_OL.CAB

I double checked to make sure I didn't have a bum image; it installs fine and the CAB files open just fine in Windows 11 explorer.

nikitalita commented 9 months ago

to reproduce, just extract the image somewhere and then run something like this:

fn test_cabs(output_folder: &Path){
    // get a list of all the CAB files in the output_folder
    let cab_files = std::fs::read_dir(output_folder).unwrap().filter(|entry| {
        entry.as_ref().unwrap().path().extension().unwrap_or(OsStr::new("")).to_ascii_lowercase() == "cab"
    }).map(|entry| entry.unwrap().path()).collect::<Vec<_>>();
    let mut failed = 0;
    let mut succeeded = 0;
    for cab_file in cab_files {
        let mut cab = Cabinet::new(File::open(cab_file.clone()).unwrap());
        if cab.is_err() {
            failed += 1;
            println!("Error opening cab file: {:?}", cab_file.clone().display());
            let cab_err_message = cab.inspect_err(|e| println!("{:?}", e));
            continue;
        }
        // println!("Opened cab file: {:?}", cab_file.clone().display());
        succeeded += 1;
    }
    println!("Succeeded: {}, Failed: {}", succeeded, failed);
}

fn main() {
    test_cabs(Path::new("./test_extract/win98")); // all the cab files are in '<CD_ROOT>/win98'
}