{{ message }}
Object parsing hardening#3956
Merged
Merged
Conversation
When parsing tree entries from raw object data, we do not verify that the tree entry actually has a filename as well as a valid object ID. Fix this by asserting that the filename length is non-zero as well as asserting that there are at least `GIT_OID_RAWSZ` bytes left when parsing the OID.
Member
Author
| GITERR_CHECK_ALLOC(commit->raw_message); | ||
| } else { | ||
| commit->raw_message = git__strdup(""); | ||
| GITERR_CHECK_ALLOC(commit->raw_message); |
Member
There was a problem hiding this comment.
Tiny nitpick: This line could be moved beneath the if/else blocks.
Member
Author
There was a problem hiding this comment.
Yeah, agreed, realized the same after posting this PR. Will change
Member
Author
There was a problem hiding this comment.
Fixed. Thanks for your careful eyes
When parsing a commit, we will treat all bytes left after parsing the headers as the commit message. When no bytes are left, we leave the commit's message uninitialized. While uncommon to have a commit without message, this is the right behavior as Git unfortunately allows for empty commit messages. Given that this scenario is so uncommon, most programs acting on the commit message will never check if the message is actually set, which may lead to errors. To work around the error and not lay the burden of checking for empty commit messages to the developer, initialize the commit message with an empty string when no commit message is given.
594a409 to
a719ef5
Compare
Member
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

See the commit messages for more info. These commits fix #3936 and #3937. I bet there are more issues around here which I'd like to find. I think I'll try some more fuzzing with AFL around the object-parsing logic sometimes soon.