Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix permissions to work with unzip #350

Merged
merged 1 commit into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/miniz.h
Original file line number Diff line number Diff line change
Expand Up @@ -8367,6 +8367,7 @@ static mz_bool mz_zip_writer_create_central_dir_header(
(void)pZip;
memset(pDst, 0, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE);
MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_SIG_OFS, MZ_ZIP_CENTRAL_DIR_HEADER_SIG);
MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_VERSION_MADE_BY_OFS, 0x031E);
MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_VERSION_NEEDED_OFS, method ? 20 : 0);
MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_BIT_FLAG_OFS, bit_flags);
MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_METHOD_OFS, method);
Expand Down
13 changes: 13 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ add_sanitizers(${test_entry_out})
set(test_permissions_out test_permissions.out)
add_executable(${test_permissions_out} test_permissions.c)
target_link_libraries(${test_permissions_out} zip)
if(LINUX OR UNIX)
find_program(UNZIP_PROGRAM unzip)
if(UNZIP_PROGRAM)
message(STATUS "Found unzip: ${UNZIP_PROGRAM}")
if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR
"${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR
"${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
target_compile_definitions(${test_permissions_out}
PRIVATE UNZIP_PROGRAM="${UNZIP_PROGRAM}"
)
endif()
endif()
endif()
add_test(NAME ${test_permissions_out} COMMAND ${test_permissions_out})
add_sanitizers(${test_permissions_out})

Expand Down
11 changes: 11 additions & 0 deletions test/test_permissions.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ MU_TEST(test_exe_permissions) {

mu_assert_int_eq(0, MZ_FILE_STAT(XFILE, &file_stats));
mu_assert_int_eq(XMODE, file_stats.st_mode);

#ifdef UNZIP_PROGRAM
remove(XFILE);

char command[128];
sprintf(command, "%s %s", UNZIP_PROGRAM, ZIPNAME);
mu_assert_int_eq(0, system(command));

mu_assert_int_eq(0, MZ_FILE_STAT(XFILE, &file_stats));
mu_assert_int_eq(XMODE, file_stats.st_mode);
#endif
}

MU_TEST(test_read_permissions) {
Expand Down
Loading