-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
exiv2: fix security issues #122511
Closed
Closed
exiv2: fix security issues #122511
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
From 4ffde8cb998cb62f4291a264225b9f274feb7002 Mon Sep 17 00:00:00 2001 | ||
From: Kevin Backhouse <kevinbackhouse@github.com> | ||
Date: Wed, 21 Apr 2021 12:06:04 +0100 | ||
Subject: [PATCH] Add more bounds checks in Jp2Image::encodeJp2Header | ||
|
||
--- | ||
src/jp2image.cpp | 3 +++ | ||
src/jp2image.cpp.rej | 18 ++++++++++++++++++ | ||
2 files changed, 21 insertions(+) | ||
create mode 100644 src/jp2image.cpp.rej | ||
|
||
diff --git a/src/jp2image.cpp b/src/jp2image.cpp | ||
index 0961203e..475439d1 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<size_t>(output.size_), Exiv2::kerCorruptedMetadata); | ||
Jp2BoxHeader* pBox = (Jp2BoxHeader*) boxBuf.pData_; | ||
int32_t length = getLong((byte*)&pBox->length, bigEndian); | ||
+ enforce(length <= static_cast<size_t>(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! | ||
diff --git a/src/jp2image.cpp.rej b/src/jp2image.cpp.rej | ||
new file mode 100644 | ||
index 00000000..43699f20 | ||
--- /dev/null | ||
+++ b/src/jp2image.cpp.rej | ||
@@ -0,0 +1,18 @@ | ||
+diff a/src/jp2image.cpp b/src/jp2image.cpp (rejected hunks) | ||
+@@ -648,13 +648,16 @@ static void boxes_check(size_t b,size_t m) | ||
+ DataBuf output(boxBuf.size_ + iccProfile_.size_ + 100); // allocate sufficient space | ||
+ long outlen = sizeof(Jp2BoxHeader) ; // now many bytes have we written to output? | ||
+ long inlen = sizeof(Jp2BoxHeader) ; // how many bytes have we read from boxBuf? | ||
++ enforce(sizeof(Jp2BoxHeader) <= static_cast<size_t>(output.size_), Exiv2::kerCorruptedMetadata); | ||
+ Jp2BoxHeader* pBox = (Jp2BoxHeader*) boxBuf.pData_; | ||
+ uint32_t length = getLong((byte*)&pBox->length, bigEndian); | ||
++ enforce(length <= static_cast<size_t>(output.size_), Exiv2::kerCorruptedMetadata); | ||
+ uint32_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! | ||
-- | ||
2.31.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably shouldn't be here, should it?