Skip to content

Fix assorted leaks found via fuzzing#4698

Merged
ethomson merged 5 commits intolibgit2:masterfrom
nelhage:fix-leaks
Jun 27, 2018
Merged

Fix assorted leaks found via fuzzing#4698
ethomson merged 5 commits intolibgit2:masterfrom
nelhage:fix-leaks

Conversation

@nelhage
Copy link
Contributor

@nelhage nelhage commented Jun 25, 2018

These were all found by my work-in-progress oss-fuzz fuzzer.

nelhage added 4 commits June 25, 2018 02:17
git__free is insufficient if the packet is a git_pkt_ref or another
type that requires freeing referenced structures.
Copy link
Member

@pks-t pks-t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR, the fixes look obviously good to me. I'd appreciate it if you could include one more commit to get rid of this if (pkt) git_pkt_free(pkt) mess, even though it's not your fault but ours. :)


while (1) {
git__free(pkt);
if (pkt) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually do not check whether a pointer is set before freeing it. But in this case it is necessary, as git_pkt_free doesn't check for NULL pointers itself


git__free(pkt);
if (pkt) {
git_pkt_free(pkt);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, one more time. I know it's not your fault, but instead the existing code is to blame. But I'd highly appreciate if you did a preliminary commit which fixes git_pkt_free to return early in case a NULL pointer is being passed to it.

@pks-t
Copy link
Member

pks-t commented Jun 25, 2018

By the way, did you already see #4433?

@nelhage
Copy link
Contributor Author

nelhage commented Jun 25, 2018

I hadn't! Thanks for the pointer, I'll look into that past attempt.

@nelhage
Copy link
Contributor Author

nelhage commented Jun 25, 2018

Fixed git_pkt_free to allow NULL.

@ethomson
Copy link
Member

Thanks for this. 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants