Skip to content

Commit

Permalink
Create parent directory before extracting symlink
Browse files Browse the repository at this point in the history
At least when using Info-ZIP 3.0, symlinks to both files and directories
lack a trailing slash, so the second mz_path_remove_filename is
unnecessary (and could break things if the parent directory doesn't
precede the symlink in the file). If other implementations do add a
trailing slash, the if statement should handle that.
  • Loading branch information
jonathan-conder-sm committed Mar 9, 2023
1 parent cee6d8c commit 7b68f0a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mz_zip_rw.c
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,9 @@ int32_t mz_zip_reader_entry_save_file(void *handle, const char *path) {
/* If symbolic link then properly construct destination path and link path */
if (mz_zip_entry_is_symlink(reader->zip_handle) == MZ_OK) {
mz_path_remove_slash(pathwfs);
mz_path_remove_filename(directory);
if (mz_zip_entry_is_dir(reader->zip_handle) == MZ_OK) {
mz_path_remove_filename(directory);
}
}

/* Create the output directory if it doesn't already exist */
Expand Down

0 comments on commit 7b68f0a

Please sign in to comment.