Skip to content

libFuzzer: Fix missing trailer crash#4432

Merged
pks-t merged 1 commit into
libgit2:masterfrom
lhchavez:fix-missing-trailer
Dec 15, 2017
Merged

libFuzzer: Fix missing trailer crash#4432
pks-t merged 1 commit into
libgit2:masterfrom
lhchavez:fix-missing-trailer

Conversation

@lhchavez
Copy link
Copy Markdown
Contributor

@lhchavez lhchavez commented Dec 6, 2017

This change fixes an invalid memory access when the trailer is missing /
corrupt.

Found using libFuzzer.

@lhchavez
Copy link
Copy Markdown
Contributor Author

lhchavez commented Dec 6, 2017

PTAL

Copy link
Copy Markdown
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 a lot for this PR, it looks obviously correct. I'd just like a small change to the provided test case here.

On another note: at some point in time, I started fuzzing various parts of libgit2, as well. I thought about building the infrastructure required to submit it to the Google fuzzing project, but I hadn't enough time/other priorities, so I lost focus. Do you have any recipes which you can share from your fuzzing setup?

Comment thread tests/pack/indexer.c Outdated

cl_git_pass(git_indexer_new(&idx, ".", 0, NULL, NULL, NULL));
cl_git_pass(git_indexer_append(
idx, missing_trailer_pack, missing_trailer_pack_len, &stats));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd prefer if you used another pack where we already verify that we're able to parse it correctly and just trim the pack_len by 1. Like that, we make sure that we're really failing because of the damaged trailer and not because the pack itself is broken.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good idea, done! Had to change it to -20, because for some reason -1 wasn't enough to trigger the leak.

@lhchavez
Copy link
Copy Markdown
Contributor Author

lhchavez commented Dec 6, 2017

Re: fuzzing recipes, I was already in the process of cleaning them up to upload them in another PR, expect them soon!

@pks-t
Copy link
Copy Markdown
Member

pks-t commented Dec 8, 2017

This PR now conflicts with the other indexer test you've added in the now-merged PR #4431. Could you please rebase? It would be nice if you could squash in the fixup commit for the test while at it.

This change fixes an invalid memory access when the trailer is missing /
corrupt.

Found using libFuzzer.
@lhchavez lhchavez force-pushed the fix-missing-trailer branch from 74c6d5a to c8aaba2 Compare December 8, 2017 14:38
@lhchavez
Copy link
Copy Markdown
Contributor Author

lhchavez commented Dec 8, 2017

Rebased+squashed.

@pks-t pks-t merged commit 2482559 into libgit2:master Dec 15, 2017
@pks-t
Copy link
Copy Markdown
Member

pks-t commented Dec 15, 2017

Thanks a lot!

@lhchavez lhchavez deleted the fix-missing-trailer branch December 15, 2017 15:02
@pks-t pks-t added the backport label Jan 11, 2018
@pks-t pks-t mentioned this pull request Jan 12, 2018
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.

2 participants