mirror of
https://github.com/zlib-ng/minizip-ng
synced 2025-03-28 21:13:18 +00:00
Fixed bugs with zstd not working with pkcrypt and causing ci to stall.
This commit is contained in:
parent
4f3401e5a4
commit
9126177377
@ -113,7 +113,7 @@ int32_t mz_stream_zstd_read(void *stream, void *buf, int32_t size) {
|
||||
int32_t out_bytes = 0;
|
||||
int32_t bytes_to_read = 0;
|
||||
int32_t read = 0;
|
||||
size_t error_code = 0;
|
||||
size_t result = 0;
|
||||
|
||||
zstd->out.dst = (void*)buf;
|
||||
zstd->out.size = (size_t)size;
|
||||
@ -140,15 +140,17 @@ int32_t mz_stream_zstd_read(void *stream, void *buf, int32_t size) {
|
||||
total_in_before = zstd->in.pos;
|
||||
total_out_before = zstd->out.pos;
|
||||
|
||||
error_code = ZSTD_decompressStream(zstd->zdstream, &zstd->out, &zstd->in);
|
||||
result = ZSTD_decompressStream(zstd->zdstream, &zstd->out, &zstd->in);
|
||||
|
||||
if (ZSTD_isError(error_code)) {
|
||||
zstd->error = error_code;
|
||||
if (ZSTD_isError(result)) {
|
||||
zstd->error = (int32_t)result;
|
||||
return MZ_DATA_ERROR;
|
||||
}
|
||||
|
||||
total_in_after = zstd->in.pos;
|
||||
total_out_after = zstd->out.pos;
|
||||
if ((zstd->max_total_out != -1) && (int64_t)total_out_after > zstd->max_total_out)
|
||||
total_out_after = (uint64_t)zstd->max_total_out;
|
||||
|
||||
in_bytes = (int32_t)(total_in_after - total_in_before);
|
||||
out_bytes = (int32_t)(total_out_after - total_out_before);
|
||||
@ -159,8 +161,7 @@ int32_t mz_stream_zstd_read(void *stream, void *buf, int32_t size) {
|
||||
zstd->total_in += in_bytes;
|
||||
zstd->total_out += out_bytes;
|
||||
|
||||
|
||||
} while (zstd->total_in != zstd->max_total_in && zstd->out.pos != zstd->out.size);
|
||||
} while (zstd->in.pos < zstd->in.size && zstd->out.pos < zstd->out.size);
|
||||
|
||||
return total_out;
|
||||
#endif
|
||||
@ -328,6 +329,7 @@ void *mz_stream_zstd_create(void **stream) {
|
||||
if (zstd != NULL) {
|
||||
memset(zstd, 0, sizeof(mz_stream_zstd));
|
||||
zstd->stream.vtbl = &mz_stream_zstd_vtbl;
|
||||
zstd->max_total_out = -1;
|
||||
}
|
||||
if (stream != NULL)
|
||||
*stream = zstd;
|
||||
|
17
mz_zip.c
17
mz_zip.c
@ -1721,6 +1721,8 @@ static int32_t mz_zip_entry_open_int(void *handle, uint8_t raw, int16_t compress
|
||||
if (zip->open_mode & MZ_OPEN_MODE_WRITE) {
|
||||
mz_stream_set_prop_int64(zip->compress_stream, MZ_STREAM_PROP_COMPRESS_LEVEL, compress_level);
|
||||
} else {
|
||||
int32_t set_end_of_stream = 0;
|
||||
|
||||
#ifndef HAVE_LIBCOMP
|
||||
if (zip->entry_raw || zip->file_info.compression_method == MZ_COMPRESS_METHOD_STORE || zip->file_info.flag & MZ_ZIP_FLAG_ENCRYPTED)
|
||||
#endif
|
||||
@ -1735,11 +1737,18 @@ static int32_t mz_zip_entry_open_int(void *handle, uint8_t raw, int16_t compress
|
||||
|
||||
mz_stream_set_prop_int64(zip->compress_stream, MZ_STREAM_PROP_TOTAL_IN_MAX, max_total_in);
|
||||
}
|
||||
if ((zip->file_info.compression_method == MZ_COMPRESS_METHOD_LZMA) && (zip->file_info.flag & MZ_ZIP_FLAG_LZMA_EOS_MARKER) == 0) {
|
||||
mz_stream_set_prop_int64(zip->compress_stream, MZ_STREAM_PROP_TOTAL_IN_MAX, zip->file_info.compressed_size);
|
||||
mz_stream_set_prop_int64(zip->compress_stream, MZ_STREAM_PROP_TOTAL_OUT_MAX, zip->file_info.uncompressed_size);
|
||||
|
||||
switch (zip->file_info.compression_method) {
|
||||
case MZ_COMPRESS_METHOD_LZMA:
|
||||
set_end_of_stream = (zip->file_info.flag & MZ_ZIP_FLAG_LZMA_EOS_MARKER);
|
||||
break;
|
||||
case MZ_COMPRESS_METHOD_ZSTD:
|
||||
case MZ_COMPRESS_METHOD_WZZSTD:
|
||||
set_end_of_stream = 1;
|
||||
break;
|
||||
}
|
||||
if ((zip->file_info.compression_method == MZ_COMPRESS_METHOD_ZSTD || zip->file_info.compression_method == MZ_COMPRESS_METHOD_WZZSTD)) {
|
||||
|
||||
if (set_end_of_stream) {
|
||||
mz_stream_set_prop_int64(zip->compress_stream, MZ_STREAM_PROP_TOTAL_IN_MAX, zip->file_info.compressed_size);
|
||||
mz_stream_set_prop_int64(zip->compress_stream, MZ_STREAM_PROP_TOTAL_OUT_MAX, zip->file_info.uncompressed_size);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user