Avoid accessing NULL when ipv6 is disabled but ipv6 args or options are used #471
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.
This fix is intended to prevent a segmentation fault.
Here is how I understood it:
In
TargetGroup.cc:661
:result << inet_ntop_ez((struct sockaddr_storage *) &this->addr, sizeof(this->addr)) << "/" << bits;
Here,
inet_ntop_ez
returnsNULL
because IPV6 is disabled by default. The calling function (or parent)NetBlockIPv6Netmask::str()
returnresult.str()
which produces a segmentation fault.With this fix,
inet_ntop_ez
do not check if IPv6 is disabled, so it will return the address even if it's disabled, then the check will be made by the parent calling functionTargetGroup::get_next_host
(targets.cc:392). Before,this->netblock->str().c_str()
was causing the crash, now the error handles it normally, telling you to add-6
option if you didn't, and if you do nmap.cc will yell at you at line 1045 because you don't have IPv6 enabled.Waiting for feedback,
Cheers