Blame SOURCES/exiv2-CVE-2018-11531.patch
|
|
4a042c |
diff --git a/src/preview.cpp b/src/preview.cpp
|
|
|
4a042c |
index c34c8bd..69f8e01 100644
|
|
|
4a042c |
--- a/src/preview.cpp
|
|
|
4a042c |
+++ b/src/preview.cpp
|
|
|
4a042c |
@@ -36,6 +36,7 @@ EXIV2_RCSID("@(#) $Id$")
|
|
|
4a042c |
|
|
|
4a042c |
#include "preview.hpp"
|
|
|
4a042c |
#include "futils.hpp"
|
|
|
4a042c |
+#include "enforce.hpp"
|
|
|
4a042c |
|
|
|
4a042c |
#include "image.hpp"
|
|
|
4a042c |
#include "cr2image.hpp"
|
|
|
4a042c |
@@ -807,13 +808,14 @@ namespace {
|
|
|
4a042c |
else {
|
|
|
4a042c |
// FIXME: the buffer is probably copied twice, it should be optimized
|
|
|
4a042c |
DataBuf buf(size_);
|
|
|
4a042c |
- Exiv2::byte* pos = buf.pData_;
|
|
|
4a042c |
+ uint32_t idxBuf = 0;
|
|
|
4a042c |
for (int i = 0; i < sizes.count(); i++) {
|
|
|
4a042c |
uint32_t offset = dataValue.toLong(i);
|
|
|
4a042c |
uint32_t size = sizes.toLong(i);
|
|
|
4a042c |
- if (offset + size <= static_cast<uint32_t>(io.size()))
|
|
|
4a042c |
- memcpy(pos, base + offset, size);
|
|
|
4a042c |
- pos += size;
|
|
|
4a042c |
+ enforce(idxBuf + size < size_, kerCorruptedMetadata);
|
|
|
4a042c |
+ if (size!=0 && offset + size <= static_cast<uint32_t>(io.size()))
|
|
|
4a042c |
+ memcpy(&buf.pData_[idxBuf], base + offset, size);
|
|
|
4a042c |
+ idxBuf += size;
|
|
|
4a042c |
}
|
|
|
4a042c |
dataValue.setDataArea(buf.pData_, buf.size_);
|
|
|
4a042c |
}
|