mirror of
https://github.com/QuasarApp/zip.git
synced 2025-04-29 13:54:35 +00:00
This commit is contained in:
parent
42151612e8
commit
114d9d46fd
12
src/zip.c
12
src/zip.c
@ -306,7 +306,7 @@ static int zip_archive_extract(mz_zip_archive *zip_archive, const char *dir,
|
|||||||
char path[MAX_PATH + 1];
|
char path[MAX_PATH + 1];
|
||||||
char symlink_to[MAX_PATH + 1];
|
char symlink_to[MAX_PATH + 1];
|
||||||
mz_zip_archive_file_stat info;
|
mz_zip_archive_file_stat info;
|
||||||
size_t dirlen = 0;
|
size_t dirlen = 0, filename_size = MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE;
|
||||||
mz_uint32 xattr = 0;
|
mz_uint32 xattr = 0;
|
||||||
|
|
||||||
memset(path, 0, sizeof(path));
|
memset(path, 0, sizeof(path));
|
||||||
@ -334,6 +334,9 @@ static int zip_archive_extract(mz_zip_archive *zip_archive, const char *dir,
|
|||||||
++dirlen;
|
++dirlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filename_size > MAX_PATH - dirlen) {
|
||||||
|
filename_size = MAX_PATH - dirlen;
|
||||||
|
}
|
||||||
// Get and print information about each file in the archive.
|
// Get and print information about each file in the archive.
|
||||||
n = mz_zip_reader_get_num_files(zip_archive);
|
n = mz_zip_reader_get_num_files(zip_archive);
|
||||||
for (i = 0; i < n; ++i) {
|
for (i = 0; i < n; ++i) {
|
||||||
@ -349,11 +352,12 @@ static int zip_archive_extract(mz_zip_archive *zip_archive, const char *dir,
|
|||||||
err = ZIP_EINVENTNAME;
|
err = ZIP_EINVENTNAME;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
strncpy_s(&path[dirlen], MAX_PATH - dirlen, info.m_filename,
|
strncpy_s(&path[dirlen], filename_size, info.m_filename,
|
||||||
MAX_PATH - dirlen);
|
filename_size);
|
||||||
#else
|
#else
|
||||||
strncpy(&path[dirlen], info.m_filename, MAX_PATH - dirlen);
|
strncpy(&path[dirlen], info.m_filename, filename_size);
|
||||||
#endif
|
#endif
|
||||||
err = zip_mkpath(path);
|
err = zip_mkpath(path);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user