mirror of
https://github.com/zlib-ng/minizip-ng
synced 2025-03-28 21:13:18 +00:00
Fixed potential infinite loop when reading LZMA with data error.
This commit is contained in:
parent
ff6f2a1db6
commit
73660f9c98
@ -152,10 +152,7 @@ int32_t mz_stream_bzip_read(void *stream, void *buf, int32_t size)
|
||||
read = mz_stream_read(bzip->stream.base, bzip->buffer, bytes_to_read);
|
||||
|
||||
if (read < 0)
|
||||
{
|
||||
bzip->error = BZ_IO_ERROR;
|
||||
break;
|
||||
}
|
||||
return read;
|
||||
if (read == 0)
|
||||
break;
|
||||
|
||||
@ -196,7 +193,7 @@ int32_t mz_stream_bzip_read(void *stream, void *buf, int32_t size)
|
||||
while (bzip->bzstream.avail_out > 0);
|
||||
|
||||
if (bzip->error != 0)
|
||||
return bzip->error;
|
||||
return MZ_DATA_ERROR;
|
||||
|
||||
return total_out;
|
||||
#endif
|
||||
|
@ -147,10 +147,7 @@ int32_t mz_stream_libcomp_read(void *stream, void *buf, int32_t size)
|
||||
read = mz_stream_read(libcomp->stream.base, libcomp->buffer, bytes_to_read);
|
||||
|
||||
if (read < 0)
|
||||
{
|
||||
libcomp->error = read;
|
||||
break;
|
||||
}
|
||||
return read;
|
||||
if (read == 0)
|
||||
break;
|
||||
|
||||
@ -182,7 +179,6 @@ int32_t mz_stream_libcomp_read(void *stream, void *buf, int32_t size)
|
||||
|
||||
if (err == COMPRESSION_STATUS_END)
|
||||
break;
|
||||
|
||||
if (err != COMPRESSION_STATUS_OK)
|
||||
{
|
||||
libcomp->error = err;
|
||||
@ -192,7 +188,7 @@ int32_t mz_stream_libcomp_read(void *stream, void *buf, int32_t size)
|
||||
while (libcomp->cstream.dst_size > 0);
|
||||
|
||||
if (libcomp->error != 0)
|
||||
return libcomp->error;
|
||||
return MZ_DATA_ERROR;
|
||||
|
||||
return total_out;
|
||||
#endif
|
||||
|
@ -179,10 +179,7 @@ int32_t mz_stream_lzma_read(void *stream, void *buf, int32_t size)
|
||||
read = mz_stream_read(lzma->stream.base, lzma->buffer, bytes_to_read);
|
||||
|
||||
if (read < 0)
|
||||
{
|
||||
lzma->error = MZ_STREAM_ERROR;
|
||||
break;
|
||||
}
|
||||
return read;
|
||||
if (read == 0)
|
||||
break;
|
||||
|
||||
@ -220,7 +217,7 @@ int32_t mz_stream_lzma_read(void *stream, void *buf, int32_t size)
|
||||
while (lzma->lstream.avail_out > 0);
|
||||
|
||||
if (lzma->error != 0)
|
||||
return lzma->error;
|
||||
return MZ_DATA_ERROR;
|
||||
|
||||
return total_out;
|
||||
#endif
|
||||
|
@ -165,10 +165,8 @@ int32_t mz_stream_zlib_read(void *stream, void *buf, int32_t size)
|
||||
read = mz_stream_read(zlib->stream.base, zlib->buffer, bytes_to_read);
|
||||
|
||||
if (read < 0)
|
||||
{
|
||||
zlib->error = Z_STREAM_ERROR;
|
||||
break;
|
||||
}
|
||||
return read;
|
||||
|
||||
if (read == 0)
|
||||
break;
|
||||
|
||||
@ -200,7 +198,6 @@ int32_t mz_stream_zlib_read(void *stream, void *buf, int32_t size)
|
||||
|
||||
if (err == Z_STREAM_END)
|
||||
break;
|
||||
|
||||
if (err != Z_OK)
|
||||
{
|
||||
zlib->error = err;
|
||||
@ -210,7 +207,10 @@ int32_t mz_stream_zlib_read(void *stream, void *buf, int32_t size)
|
||||
while (zlib->zstream.avail_out > 0);
|
||||
|
||||
if (zlib->error != 0)
|
||||
{
|
||||
// Zlib errors are compatible with MZ
|
||||
return zlib->error;
|
||||
}
|
||||
|
||||
return total_out;
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user