-
Notifications
You must be signed in to change notification settings - Fork 282
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
fix(quicktimevideo) avoid out of bounds read, closes #2340 #2341
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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
Binary file not shown.
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,13 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from system_tests import CaseMeta, check_no_ASAN_UBSAN_errors | ||
|
||
class issue_2320_printDegrees_integer_overflow(metaclass=CaseMeta): | ||
url = "https://github.com/Exiv2/exiv2/issues/2340" | ||
filename = "$data_path/issue_2340_poc.mp4" | ||
commands = ["$exiv2 -q -pa $filename"] | ||
retval = [1] | ||
stderr = ["""$exiv2_exception_message $filename: | ||
$kerCorruptedMetadata | ||
"""] | ||
compare_stdout = check_no_ASAN_UBSAN_errors |
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.
I checked the documentation on this: it will copy 4 bytes even if some of them are null. So
std::string::size()
will return 4 even if the string is actually shorter than that, which is a bit weird. So I wonder if it would be better to increase the size ofbuf
to 5 and put a nul-terminator inbuf[4]
.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.
Hi Kevin. I also looked a bit in this function, and this line looked safe to me, taking into account that in line 660 the
DataBuf
instance is of size 4, and in line 667 we doio_->readOrThrow(buf.data(), 4);
.What it might prevent additional changes in the future would be to do
io_->readOrThrow(buf.data(), buf.size());
just in case the side of theDataBuf
instance changes in the future.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.
@piponazo: Yes, I think this line of code is safe. The problem that I'm talking about is only a very minor thing. This is a demo of the weird thing that can happen:
It prints this:
But you might expect it to print this:
If we never call
size()
on the string then it doesn't even matter.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.
I figured as a first step, this is a quick fix that fixes the out-of-bounds read.
I think what we really want is a safer utility to read strings. Maybe something like a
read_string
function on databuf similar to theread_uintxx
functions. But that is a larger refactor that I didn't have time to implement.