archive/zzip: fix crash on corrupt ZIP file
Sometimes, zzip_file_read() returns 0 even though the end of the file was not reached. This causes assertion failures in DecoderBridge::Read(). Closes https://github.com/MusicPlayerDaemon/MPD/issues/935
This commit is contained in:
parent
e44b953d9a
commit
1f6a7d6462
2
NEWS
2
NEWS
|
@ -2,6 +2,8 @@ ver 0.21.26 (not yet released)
|
||||||
* output
|
* output
|
||||||
- osx: fix crash bug
|
- osx: fix crash bug
|
||||||
- sles: support floating point samples
|
- sles: support floating point samples
|
||||||
|
* archive
|
||||||
|
- zzip: fix crash on corrupt ZIP file
|
||||||
* decoder
|
* decoder
|
||||||
- sndfile: fix lost samples at end of file
|
- sndfile: fix lost samples at end of file
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,8 @@
|
||||||
|
|
||||||
#include <zzip/zzip.h>
|
#include <zzip/zzip.h>
|
||||||
|
|
||||||
|
#include <inttypes.h> /* for PRIoffset (PRIu64) */
|
||||||
|
|
||||||
struct ZzipDir {
|
struct ZzipDir {
|
||||||
ZZIP_DIR *const dir;
|
ZZIP_DIR *const dir;
|
||||||
|
|
||||||
|
@ -151,6 +153,11 @@ ZzipInputStream::Read(void *ptr, size_t read_size)
|
||||||
if (nbytes < 0)
|
if (nbytes < 0)
|
||||||
throw std::runtime_error("zzip_file_read() has failed");
|
throw std::runtime_error("zzip_file_read() has failed");
|
||||||
|
|
||||||
|
if (nbytes == 0 && !IsEOF())
|
||||||
|
throw FormatRuntimeError("Unexpected end of file %s"
|
||||||
|
" at %" PRIoffset " of %" PRIoffset,
|
||||||
|
GetURI(), GetOffset(), GetSize());
|
||||||
|
|
||||||
offset = zzip_tell(file);
|
offset = zzip_tell(file);
|
||||||
return nbytes;
|
return nbytes;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue