summaryrefslogtreecommitdiff
path: root/hwpfilter
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-10-26 11:36:48 +0100
committerCaolán McNamara <caolanm@redhat.com>2017-10-27 09:57:55 +0200
commit005ad924ce183b1f07f2e6193b5befac6fdda2b8 (patch)
tree76a8fd0afa9d7ca3570fb3059ca30e5c777ff58a /hwpfilter
parente027d2956834a716b400a32dfdb4b0adfaeaa2f6 (diff)
hwp fuzzing timeout
Change-Id: I88656c558dfe1ef6e701ba54633bfe251bc4e279 Reviewed-on: https://gerrit.libreoffice.org/43884 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'hwpfilter')
-rw-r--r--hwpfilter/source/hwpread.cxx15
1 files changed, 8 insertions, 7 deletions
diff --git a/hwpfilter/source/hwpread.cxx b/hwpfilter/source/hwpread.cxx
index 826272f8eb74..33ff358e44fa 100644
--- a/hwpfilter/source/hwpread.cxx
+++ b/hwpfilter/source/hwpread.cxx
@@ -444,17 +444,18 @@ bool Picture::Read(HWPFile & hwpf)
//read potentially compressed data in blocks as its more
//likely large values are simply broken and we'll run out
//of data before we need to realloc
- for (size_t i = 0; i < follow_block_size; i+= SAL_MAX_UINT16)
+ unsigned char buffer[SAL_MAX_UINT16];
+ for (size_t i = 0; i < follow_block_size; i+= SAL_N_ELEMENTS(buffer))
{
size_t nOldSize = follow.size();
- size_t nBlock = std::min<size_t>(SAL_MAX_UINT16, follow_block_size - nOldSize);
- follow.resize(nOldSize + nBlock);
- size_t nReadBlock = hwpf.Read1b(follow.data() + nOldSize, nBlock);
- if (nBlock != nReadBlock)
+ size_t nBlock = std::min(SAL_N_ELEMENTS(buffer), follow_block_size - nOldSize);
+ size_t nReadBlock = hwpf.Read1b(buffer, nBlock);
+ if (nReadBlock)
{
- follow.resize(nOldSize + nReadBlock);
- break;
+ follow.insert(follow.end(), buffer, buffer + nReadBlock);
}
+ if (nBlock != nReadBlock)
+ break;
}
follow_block_size = follow.size();