Eliminate crash in mac_prefix_init() on platforms with 32-bit long - #2732
Closed
chrstphrchvz wants to merge 1 commit into
Closed
Eliminate crash in mac_prefix_init() on platforms with 32-bit long#2732chrstphrchvz wants to merge 1 commit into
mac_prefix_init() on platforms with 32-bit long#2732chrstphrchvz wants to merge 1 commit into
Conversation
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 type of
(pfx & 0xfffffffffL)isuint64_t, which isunsigned long longon platforms with 32-bitlong(as well as some platforms with 64-bitlong). But%0*lXin the format string expects typeunsigned long, which the compiler already warns about:nmap-mac-prefixes currently does not contain any duplicate entries. But if it did contain a duplicate entry, and nmap is run with debug level 2 or higher, then a crash will occur on 32-bit systems due to part of
(pfx & 0xfffffffffL)being mistaken for the address of thefilenamebuffer; on little endian systems, the invalid address is either the leading digit of a 36-bit MAC prefix, otherwise 0.Example command which triggers this crash, after editing nmap-mac-prefixes to contain a duplicate entry:
This crash can be eliminated by using the correct format specifier for
uint64_t. I have tested this approach on IA-32 Linux as a patch for nmap 7.94, which is currently the only release affected by this issue.