summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2017-04-20 15:26:04 +0200
committerDavid Tardon <dtardon@redhat.com>2017-04-20 15:26:04 +0200
commit5115e1a1882e378133c024349a8d329d88ba64df (patch)
treee9fc502460ea6ce626e268f8741b9c4c7e27f1ca
parent3214f15d8296f203821d71b2a0800a14b2f0ca32 (diff)
ofz#1023 avoid stack overflow with too big list level
Change-Id: I3810cfc334f5c9053e7f2302fe3034d87d57bc70
-rw-r--r--src/lib/ABWContentCollector.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/lib/ABWContentCollector.cpp b/src/lib/ABWContentCollector.cpp
index feec8a6..09c4319 100644
--- a/src/lib/ABWContentCollector.cpp
+++ b/src/lib/ABWContentCollector.cpp
@@ -20,6 +20,7 @@
#include "libabw_internal.h"
#define ABW_EPSILON 1.0E-06
+#define MAX_LIST_LEVEL 64 // a safeguard against damaged files
using boost::optional;
@@ -592,6 +593,8 @@ void libabw::ABWContentCollector::collectParagraphProperties(const char *level,
_closeBlock();
if (!level || !findInt(level, m_ps->m_currentListLevel) || m_ps->m_currentListLevel < 1)
m_ps->m_currentListLevel = 0;
+ if (m_ps->m_currentListLevel > MAX_LIST_LEVEL)
+ m_ps->m_currentListLevel = MAX_LIST_LEVEL;
if (!listid || !findInt(listid, m_ps->m_currentListId) || m_ps->m_currentListId < 0)
m_ps->m_currentListId = 0;