summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-07-10 08:40:42 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-07-10 08:58:21 +0100
commitfd2749455fe25e24b448a44f9ada6113e5ac0d13 (patch)
tree5917e4474f7efa17398a8744e8dbb4d77bd94a9a
parent5b2f8231945fedc46425e00f1234dcac90628c1d (diff)
avoid endless loop with busted wmf
Change-Id: I104de360f2e861e959ad2dad434a768440877f6f
-rw-r--r--vcl/qa/cppunit/graphicfilter/data/wmf/fail/hang-1.wmfbin0 -> 675 bytes
-rw-r--r--vcl/source/filter/wmf/winwmf.cxx10
2 files changed, 7 insertions, 3 deletions
diff --git a/vcl/qa/cppunit/graphicfilter/data/wmf/fail/hang-1.wmf b/vcl/qa/cppunit/graphicfilter/data/wmf/fail/hang-1.wmf
new file mode 100644
index 000000000000..7ba05cb00219
--- /dev/null
+++ b/vcl/qa/cppunit/graphicfilter/data/wmf/fail/hang-1.wmf
Binary files differ
diff --git a/vcl/source/filter/wmf/winwmf.cxx b/vcl/source/filter/wmf/winwmf.cxx
index 343b74f54a15..7b87f68a0013 100644
--- a/vcl/source/filter/wmf/winwmf.cxx
+++ b/vcl/source/filter/wmf/winwmf.cxx
@@ -1394,9 +1394,13 @@ void WMFReader::ReadWMF()
}
}
}
- nPos += nRecSize * 2;
- if ( nPos <= nEndPos )
- pWMF->Seek( nPos );
+ const sal_uInt32 nAvailableBytes = nEndPos - nPos;
+ const sal_uInt32 nMaxPossibleRecordSize = nAvailableBytes/2;
+ if (nRecSize <= nMaxPossibleRecordSize)
+ {
+ nPos += nRecSize * 2;
+ pWMF->Seek(nPos);
+ }
else
pWMF->SetError( SVSTREAM_FILEFORMAT_ERROR );
}