summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2015-08-25 16:12:25 +0200
committerDavid Tardon <dtardon@redhat.com>2015-08-25 16:12:25 +0200
commit4700056698abce223b3da120d58019c4626b5e57 (patch)
tree613e85dde12ee0ae92aadf3a14ffd0d387960aa3 /src
parent7128ea06e51c712a549d95237093b836eee4db8f (diff)
afl: avoid out of bounds access to vector
Change-Id: I51fdad6cca395bb5aadc916ef452ee020f666607
Diffstat (limited to 'src')
-rw-r--r--src/lib/VSDMetaData.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/lib/VSDMetaData.cpp b/src/lib/VSDMetaData.cpp
index 00dca07..7241b00 100644
--- a/src/lib/VSDMetaData.cpp
+++ b/src/lib/VSDMetaData.cpp
@@ -8,6 +8,7 @@
*/
#include "VSDMetaData.h"
+#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
@@ -238,6 +239,9 @@ librevenge::RVNGString libvisio::VSDMetaData::readCodePageString(librevenge::RVN
{
uint32_t size = readU32(input);
+ if (size == 0)
+ return librevenge::RVNGString();
+
std::vector<unsigned char> characters;
for (uint32_t i = 0; i < size; ++i)
characters.push_back(readU8(input));
@@ -267,6 +271,7 @@ librevenge::RVNGString libvisio::VSDMetaData::readCodePageString(librevenge::RVN
if (U_SUCCESS(status) && conv)
{
+ assert(!characters.empty());
const char *src = (const char *)&characters[0];
const char *srcLimit = (const char *)src + characters.size();
while (src < srcLimit)