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(linux): off by one error caused list_afinet_netifas to omit the last ip address #93

Merged
merged 1 commit into from
Nov 24, 2022

Conversation

D1plo1d
Copy link
Contributor

@D1plo1d D1plo1d commented Nov 24, 2022

This PR fixes an issue in the Linux implementation where a while condition checked if the next item (ifa_next) would be null before it consumed the current item (ifa). This caused the loop to always skip the last ip address, causing it to be omitted from the list returned by list_afinet_netifas().

@LeoBorai LeoBorai changed the title fix(linux): Off by one error caused list_afinet_netifas to omit the last ip address fix(linux): off by one error caused list_afinet_netifas to omit the last ip address Nov 24, 2022
Copy link
Owner

@LeoBorai LeoBorai left a comment

Choose a reason for hiding this comment

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

LGTM!

@LeoBorai
Copy link
Owner

@D1plo1d nice work!

@LeoBorai LeoBorai merged commit ff28f7c into LeoBorai:main Nov 24, 2022
@jakewilliami
Copy link
Contributor

What a coincidence! We must have both discovered this error at a similar time (see 3524c0b) 🙂

@D1plo1d D1plo1d deleted the fix/linux-off-by-one branch November 29, 2022 15:29
cgzones added a commit to cgzones/local-ip-address that referenced this pull request Feb 27, 2023
Rewrite the Linux version of list_afinet_netifas() using netlink
requests in pure Rust instead of calling the libc interface
getifaddrs(3).  This avoids pointer magic and calling unsafe C code.
See LeoBorai#88 and LeoBorai#93 for exemplary issues.
cgzones added a commit to cgzones/local-ip-address that referenced this pull request Feb 27, 2023
Rewrite the Linux version of list_afinet_netifas() using netlink
requests in pure Rust instead of calling the libc interface
getifaddrs(3).  This avoids pointer magic and calling unsafe C code.
See LeoBorai#88 and LeoBorai#93 for exemplary issues.
cgzones added a commit to cgzones/local-ip-address that referenced this pull request Feb 28, 2023
Rewrite the Linux version of list_afinet_netifas() using netlink
requests in pure Rust instead of calling the libc interface
getifaddrs(3).  This avoids pointer magic and calling unsafe C code.
See LeoBorai#88 and LeoBorai#93 for exemplary issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants