From 6d9c791b371f36c7186a43d9d25cb7d45e12a636 Mon Sep 17 00:00:00 2001 From: Packit Bot Date: May 05 2021 22:16:38 +0000 Subject: Apply patch exiv2-CVE-2021-29470.patch patch_name: exiv2-CVE-2021-29470.patch present_in_specfile: true location_in_specfile: 4 --- diff --git a/src/jp2image.cpp b/src/jp2image.cpp index 0961203..475439d 100644 --- a/src/jp2image.cpp +++ b/src/jp2image.cpp @@ -648,13 +648,16 @@ static void boxes_check(size_t b,size_t m) DataBuf output(boxBuf.size_ + iccProfile_.size_ + 100); // allocate sufficient space int outlen = sizeof(Jp2BoxHeader) ; // now many bytes have we written to output? int inlen = sizeof(Jp2BoxHeader) ; // how many bytes have we read from boxBuf? + enforce(sizeof(Jp2BoxHeader) <= static_cast(output.size_), Exiv2::kerCorruptedMetadata); Jp2BoxHeader* pBox = (Jp2BoxHeader*) boxBuf.pData_; int32_t length = getLong((byte*)&pBox->length, bigEndian); + enforce(length <= static_cast(output.size_), Exiv2::kerCorruptedMetadata); int32_t count = sizeof (Jp2BoxHeader); char* p = (char*) boxBuf.pData_; bool bWroteColor = false ; while ( count < length || !bWroteColor ) { + enforce(sizeof(Jp2BoxHeader) <= length - count, Exiv2::kerCorruptedMetadata); Jp2BoxHeader* pSubBox = (Jp2BoxHeader*) (p+count) ; // copy data. pointer could be into a memory mapped file which we will decode!