Bugfix/crash in ares sortaddrinfo#400
Merged
bradh352 merged 2 commits intoMar 5, 2021
Merged
Conversation
The bug was generated because there was not check for the number of items in the list and invalid memory was accesed when the list was empty. There is a check for null after calling malloc but on some systems it always returns a valid address for size equals 0. For e.g., on macOS and Windows systems malloc returns a valid address: https://man.openbsd.org/malloc.3 https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/malloc However, on Linux malloc returns NULL if size equals 0: https://man7.org/linux/man-pages/man3/malloc.3.html Also, the openBSD manual says it more clearly: If nmemb or size is equal to 0, a unique pointer to an access protected, zero sized object is returned. Access via this pointer will generate a SIGSEGV exception. Relates To: c-ares#392, 0903dce
sergepetrenko
pushed a commit
to tarantool/c-ares
that referenced
this pull request
Jul 29, 2022
The bug was generated because there was no check for the number of items in the list and invalid memory was accesed when the list was empty. There is a check for null after calling malloc but on some systems it always returns a valid address for size equals 0. Relates To: c-ares#392, 0903dce Fix By: @catalinh-bd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The patch set contains the following:
ares__sortaddrinfowhen sending an empty list