Kaydet (Commit) e3e2cf30 authored tarafından Michael Stahl's avatar Michael Stahl

libmwaw: fix infinite loop in findCentralDirectoryEnd

Change-Id: I36ec7ad735fa15cfda88167b11a922883ef2bb72
üst 7694bb99
......@@ -13,6 +13,7 @@ $(eval $(call gb_UnpackedTarball_set_tarball,libmwaw,$(MWAW_TARBALL)))
$(eval $(call gb_UnpackedTarball_add_patches,libmwaw,\
libmwaw/libmwaw-0.1.9.patch.1 \
libmwaw/libmwaw-infinite-loop.patch.1 \
))
# vim: set noet sw=4 ts=4:
fix infinite loop in findCentralDirectoryEnd
WPXSvInputStreamImpl::seek returns -1 if it catches an exception
--- libmwaw/src/lib/MWAWZipStream.cxx 2013-06-18 00:37:57.208657845 +0200
+++ libmwaw/src/lib/MWAWZipStream.cxx 2013-06-18 00:48:20.971665257 +0200
@@ -258,18 +258,20 @@
static bool findCentralDirectoryEnd(WPXInputStream *input)
{
- input->seek(0, WPX_SEEK_SET);
+ // seek returns -1 both on error and on seek to position post-the-end
+ int ret = input->seek(0, WPX_SEEK_SET);
try {
- while (!input->atEOS())
- input->seek(1024, WPX_SEEK_CUR);
+ while (-1 != ret && !input->atEOS())
+ ret = input->seek(1024, WPX_SEEK_CUR);
input->seek(-1024, WPX_SEEK_CUR);
- while (!input->atEOS()) {
+ ret = 0; // perhaps it's smaller than 1024?
+ while (-1 != ret && !input->atEOS()) {
unsigned signature = getInt(input);
if (signature == CDIR_END_SIG) {
input->seek(-4, WPX_SEEK_CUR);
return true;
} else
- input->seek(-3, WPX_SEEK_CUR);
+ ret = input->seek(-3, WPX_SEEK_CUR);
}
} catch (...) {
return false;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment