ZIP_CM_SHRINK and ZIP_CM_IMPLODE give unsupported compression method error
Describe the Bug It appears the compression methods ZIP_CM_SHRINK and ZIP_CM_IMPLODE are unsupported.
Expected Behavior My zip file should be able to be uncompressed.
Observed Behavior It gives an error and does not uncompress my zip file.
To Reproduce I've found 2 archives that show this behavior and wrote a minimal C program to reproduce.
https://www.whicken.com/scorch/scorch15.zip https://www.whicken.com/scorch/scorch12.zip
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <zip.h>
int main(int argc, char **argv)
{
if (argc < 2) {
fprintf(stderr, "Not enough arguments\n");
return EXIT_FAILURE;
}
zip_t *zip = zip_open(argv[1], ZIP_RDONLY, NULL);
if (!zip) {
fprintf(stderr, "Failed to open: %s\n", argv[1]);
return EXIT_FAILURE;
}
int64_t num_entries = zip_get_num_entries(zip, 0);
printf("Number of entries: %ld\n", num_entries);
char buffer[4096];
for (int64_t i = 0; i < num_entries; ++i) {
struct zip_stat stat;
if (zip_stat_index(zip, i, 0, &stat) != 0) {
fprintf(stderr, "Failed to stat for entry %ld\n", i);
continue;
}
printf("%ld: %s: Compression Method: %d\n", i, stat.name, stat.comp_method);
zip_file_t *file = zip_fopen_index(zip, i, 0);
if (!file) {
fprintf(stderr, "Failed to open: %s\n", zip_strerror(zip));
continue;
}
int64_t bytes;
do {
bytes = zip_fread(file, &buffer, sizeof(buffer));
if (bytes == -1) {
fprintf(stderr, "Read error\n");
}
} while (bytes > 0);
zip_fclose(file);
}
return EXIT_SUCCESS;
}
stat.comp_method shows ZIP_CM_SHRINK and ZIP_CM_SHRINK being used. The error happens on the call to zip_fopen_index. The Linux version of Info-Zip can handle these archives and unzip -v scorch12.zip confirms the methods being used are shrink and implode. libzip does not handle these.
libzip Version 1.10.1
Operating System Arch Linux
Test Files https://www.whicken.com/scorch/scorch15.zip https://www.whicken.com/scorch/scorch12.zip
Additional context This is also reproachable from the GUI program Ark (made by KDE) which uses libzip internally.
That's to be expected, since libzip does not support these compression methods. We currently don't have plans to implement them, but we would accept patches/pull requests.