Blame SOURCES/exiv2-CVE-2021-37618.patch
|
|
aa9105 |
From dbf472751fc8b87ea7d1de02f54eaf64233a2fb6 Mon Sep 17 00:00:00 2001
|
|
|
aa9105 |
From: Kevin Backhouse <kevinbackhouse@github.com>
|
|
|
aa9105 |
Date: Mon, 5 Jul 2021 10:40:03 +0100
|
|
|
aa9105 |
Subject: [PATCH 2/2] Better bounds checking in Jp2Image::printStructure
|
|
|
aa9105 |
|
|
|
aa9105 |
---
|
|
|
aa9105 |
src/jp2image.cpp | 2 ++
|
|
|
aa9105 |
1 file changed, 2 insertions(+)
|
|
|
aa9105 |
|
|
|
aa9105 |
diff --git a/src/jp2image.cpp b/src/jp2image.cpp
|
|
|
aa9105 |
index 43c93d7..a8c37e8 100644
|
|
|
aa9105 |
--- a/src/jp2image.cpp
|
|
|
aa9105 |
+++ b/src/jp2image.cpp
|
|
|
aa9105 |
@@ -42,6 +42,7 @@ EXIV2_RCSID("@(#) $Id$")
|
|
|
aa9105 |
#include "futils.hpp"
|
|
|
aa9105 |
#include "types.hpp"
|
|
|
aa9105 |
#include "safe_op.hpp"
|
|
|
aa9105 |
+#include "enforce.hpp"
|
|
|
aa9105 |
|
|
|
aa9105 |
// + standard includes
|
|
|
aa9105 |
#include <string>
|
|
|
aa9105 |
@@ -511,6 +512,7 @@ namespace Exiv2
|
|
|
aa9105 |
if(subBox.type == kJp2BoxTypeColorHeader)
|
|
|
aa9105 |
{
|
|
|
aa9105 |
long pad = 3 ; // don't know why there are 3 padding bytes
|
|
|
aa9105 |
+ enforce(data.size_ >= pad, kerCorruptedMetadata);
|
|
|
aa9105 |
if ( bPrint ) {
|
|
|
aa9105 |
out << " | pad:" ;
|
|
|
aa9105 |
for ( int i = 0 ; i < 3 ; i++ ) out<< " " << (int) data.pData_[i];
|
|
|
aa9105 |
@@ -521,6 +523,7 @@ namespace Exiv2
|
|
|
aa9105 |
}
|
|
|
aa9105 |
|
|
|
aa9105 |
DataBuf icc(iccLength);
|
|
|
aa9105 |
+ enforce(iccLength <= data.size_ - pad, kerCorruptedMetadata);
|
|
|
aa9105 |
if ( bICC ) out.write((const char*)icc.pData_,icc.size_);
|
|
|
aa9105 |
}
|
|
|
aa9105 |
lf(out,bLF);
|