Skip to content

Commit

Permalink
Merge pull request smihica#32 from veon82/fix_leading_slash_on_empty_…
Browse files Browse the repository at this point in the history
…prefix

Fix _compress(): don't add slash on filepath if prefix is an empty st…
  • Loading branch information
smihica authored Aug 20, 2021
2 parents 198e6c4 + 2df6049 commit 6a5cd5e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def read(fname):

setup(
name = 'pyminizip',
version = '0.2.4',
version = '0.2.4.1',
description = 'A minizip wrapper - To create a password encrypted zip file in python.',
author='Shin Aoyama',
author_email = "[email protected]",
Expand Down
10 changes: 8 additions & 2 deletions src/py_minizip.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,14 @@ int _compress(const char** srcs, int src_num, const char** srcspath, int srcpath
slash = &default_slash;
}
}
if (savefilepathnameinzip[filepathname_len-1] != *slash)
extra_len = 1;

/* NOTE:
don't add slash if filepathname_len is zero (prefix is an empty string)
and avoid memory access violation */
if (filepathname_len > 0) {
if (savefilepathnameinzip[filepathname_len-1] != *slash)
extra_len = 1;
}
/* allocate buffer */
fullpathfileinzip = (char *)malloc(filename_len + filepathname_len + extra_len + 1);
if (fullpathfileinzip == NULL) {
Expand Down

0 comments on commit 6a5cd5e

Please sign in to comment.