commit: verify objects exist in git_commit_with_signature#5289
Conversation
…nature There can be a significant difference between the system where we created the buffer (if at all) and when the caller provides us with the contents of a commit. Provide some test cases (we have to adapt the existing ones because they refer to trees and commits which do not exist).
There can be a significant difference between the system where we created the buffer (if at all) and when the caller provides us with the contents of a commit. Verify that the commit we are being asked to create references objects which do exist in the target repository.
| goto cleanup; | ||
|
|
||
| if ((error = validate_tree_and_parents(&parents, repo, &parsed->tree_id, commit_parent_from_commit, parsed, NULL, true)) < 0) | ||
| goto cleanup; |
There was a problem hiding this comment.
Is it certain that parents doesn't have to be cleared if validate_tree_and_parents returns an error?
There was a problem hiding this comment.
Looks like it to me - the error case of validate_tree_and_parents fn will clear the parents array before returning, if it had ever allocated anything into it.
|
LGTM. Thanks, @carlosmn, for finding and fixing strange ordering bugs! |
|
It looks like the existing This limitation doesn't hold this up, since it's an important fix. But I wanted to ask. |
Do you mean |
Yes, somehow I forgot how variables work and boolean logic. Thanks! |
There can be a significant difference between the system where we created the
buffer (if at all) and when the caller provides us with the contents of a
commit.
Verify that the commit we are being asked to create references objects which do
exist in the target repository.
This is not terribly efficient since we allocate a commit, but AFAICT it's what we have available. Obviously our test suite fails with these changes because we were creating commits that referenced non-existent trees and commits.
Fixes #5288