You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a potential buffer overlap in SystemNative_GetNetworkInterfaces by ensuring the native allocation always reserves space for both the returned NetworkInterfaceInfo array and the IpAddressInfo array, even when getifaddrs returns only IPv4/IPv6 entries (so count == ip4count + ip6count).
Changes:
Make the allocation size always account for count + ip4count + ip6count entries to prevent overwriting the interface array.
Set addressList to start immediately after NetworkInterfaceInfo[count] (instead of a computed offset that can become 0).
Remove the Android-only conditional sizing logic and replace it with a platform-agnostic approach.
On allocation failure, the getifaddrs() result in head is not freed before returning. This leaks the ifaddrs list in the OOM path; please call freeifaddrs(head) before setting errno/returning (and keep head valid for that call).
Not only Android might see count = ip4count + ip6count,
which would lead to overwriting the NetworkInterfaceInfo
this is meant to return.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Not only Android might see count = ip4count + ip6count, which would lead
to overwriting the NetworkInterfaceInfo this is meant to return.
Something I discovered while working on
#124728
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Tomas Weinfurt <tweinfurt@yahoo.com>
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
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.
Not only Android might see count = ip4count + ip6count, which would lead to overwriting the NetworkInterfaceInfo this is meant to return.
Something I discovered while working on #124728