Skip to content

Add fuzzing support in libmaxminddb - #357

Merged
horgh merged 2 commits into
maxmind:mainfrom
pkillarjun:fuzzing
Nov 8, 2024
Merged

horgh merged 2 commits into
maxmind:mainfrom
pkillarjun:fuzzing

Conversation

@pkillarjun

@pkillarjun pkillarjun commented Nov 5, 2024 •

Copy link
Copy Markdown
Contributor

These are the bugs i found #356

My plans are to integrate libmaxminddb into OSS-Fuzz.

Signed-off-by: Arjun <pkillarjun@protonmail.com>

@horgh horgh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cool! I have a few comments.

Comment thread README.md Resolved
Comment thread t/fuzz_mmdb.c
if (status == MMDB_SUCCESS)
MMDB_close(&mmdb);

unlink(filename);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would we want to error check any of these calls? This one, fwrite, fclose, sprintf could all have their return values checked I think.

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.

This one, fwrite, fclose, sprintf could all have their return values checked I think.

Good idea, but too much voodoo, I guess.

Comment thread t/fuzz_mmdb.c

fp = fopen(filename, "wb");
if (!fp)
return 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this or the above return something other than 0?

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.

Should this or the above return something other than 0?

No, if the program returns anything else other than return 0;, the coverage won't be counted.
I get it; we could use return -1; or return 1;, but I would say let's keep it return 0; for consistency.

Souce LibFuzzer

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would we want it to be counted though? It's an error, right?

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.

It's an error, right?

It is an error. I think there are bigger problems in your system if you see these errors.
We would be running in a controlled environment, so it won't be a problem.

Signed-off-by: Arjun <pkillarjun@protonmail.com>
@horgh
horgh merged commit d308c75 into maxmind:main Nov 8, 2024
horgh added a commit that referenced this pull request Nov 8, 2024
oschwald added a commit that referenced this pull request Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants