libnet_if_addr.c: fix segfault when number of IPs > 512#150
Merged
troglobit merged 1 commit intolibnet:masterfrom Nov 23, 2022
Merged
libnet_if_addr.c: fix segfault when number of IPs > 512#150troglobit merged 1 commit intolibnet:masterfrom
troglobit merged 1 commit intolibnet:masterfrom
Conversation
troglobit
requested changes
Nov 23, 2022
Collaborator
|
Thanks for submitting this PR! Please update it with my comments and rebase+squash that. |
The current code has a hardcoded limit of 512 IP addresses. The static array will be overflowed when more addresses are present. Fix the static limit by using realloc when the array needs to grow to accomodate more interfaces. Growing the array by a factor of 1.5 each time (close to golden ratio) to maximize reuse of previously allocated space.
b677cfd to
8b4688c
Compare
troglobit
approved these changes
Nov 23, 2022
Collaborator
|
Looks awesome, great work! Unleashing CI, when it completes I'll merge :-) |
troglobit
added a commit
that referenced
this pull request
Dec 28, 2022
libnet has multiple libnet_ifaddrlist(), one for each OS family. The changes in PR #150, fixing the aribtrary MAX IP address limit on LInux, unfortunately broke all other operating systems. This change is for the "other" operating system that are not Windows. Tested on macOS. Issue #150 Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
troglobit
added a commit
that referenced
this pull request
Dec 28, 2022
libnet has multiple libnet_ifaddrlist(), one for each OS family. The changes in PR #150, fixing the aribtrary MAX IP address limit on LInux, unfortunately broke all other operating systems. This is a specualtive change for the Windows operating system, untested. Issue #150 Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Collaborator
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 current code has a hardcoded limit of 512 IP addresses. The static array will be overflowed when more addresses are present.
Fix the static limit by using realloc when the array needs to grow to accomodate more interfaces.
I verified on a setup with 1200+ interfaces/IPs and also ran valgrind to confirm there's no memory leak.
Closes: #149