Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix heap buffer overflow #237

Merged
merged 2 commits into from Aug 6, 2020
Merged

Fix heap buffer overflow #237

merged 2 commits into from Aug 6, 2020

Conversation

oschwald
Copy link
Member

@oschwald oschwald commented Aug 5, 2020

Closes #236.

@oschwald
Copy link
Member Author

oschwald commented Aug 5, 2020

I did some benchmarking and didn't see any performance difference.

The particular issue in #236 was our failure to null terminate the string when the size was zero.

Copy link
Contributor

@horgh horgh left a comment

Choose a reason for hiding this comment

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

👍

bin/mmdblookup.c Outdated
@@ -79,9 +79,9 @@ int wmain(int argc, wchar_t **wargv)
GetLastError());
exit(1);
}
utf8_string = malloc(utf8_width);
utf8_string = calloc(1, utf8_width);
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this one make more sense with the arguments reversed? Maybe with a sizeof(char)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! I force-pushed a fix.

@oschwald oschwald force-pushed the greg/fix-heap-buffer-overflow branch from c8d83e6 to 3f4eb87 Compare August 5, 2020 22:40
@horgh horgh merged commit 5dda63a into master Aug 6, 2020
4 checks passed
@horgh horgh deleted the greg/fix-heap-buffer-overflow branch August 6, 2020 16:07
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.

A heap-buffer-overflow in maxminddb.c:2019:13
2 participants