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

issue: 3981627 [GTEST] Fix default gateway detection #195

Open
wants to merge 2 commits into
base: vNext
Choose a base branch
from

Conversation

pasis
Copy link
Member

@pasis pasis commented Jul 17, 2024

Description

sys_str2addr() converts a string address representation to the sockaddr
structure. However, an invalid address sets either AF_INET or AF_INET6
address family and returns corrupted IP portion of the sockaddr object.

Return AF_UNSPEC address family in case of an invalid IP address. So,
default gateway detection can handle address parsing.

Invalid port portion is still silently ignored. In the future, the
function should return the conversion status and this needs to be
handled explicitly by the function users.

sys_gateway() converts string address to a temporary sockaddr object
on stack before changing the result object. However, a different
uninitialized object is checked for the conversion status.

Check the correct object.

What

Fix default gateway detection.

Why ?

Fix incorrect gateway detection in corner cases.

Change type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Tests
  • Other

Check list

  • Code follows the style de facto guidelines of this project
  • Comments have been inserted in hard to understand places
  • Documentation has been updated (if necessary)
  • Test has been added (if possible)

sys_str2addr() converts a string address representation to the sockaddr
structure. However, an invalid address sets either AF_INET or AF_INET6
address family and returns corrupted IP portion of the sockaddr object.

Return AF_UNSPEC address family in case of an invalid IP address. So,
default gateway detection can handle address parsing.

Invalid port portion is still silently ignored. In the future, the
function should return the conversion status and this needs to be
handled explicitly by the function users.

Signed-off-by: Dmytro Podgornyi <dmytrop@nvidia.com>
sys_gateway() converts string address to a temporary sockaddr object
on stack before changing the result object. However, a different
uninitialized object is checked for the conversion status.

Check the correct object.

Signed-off-by: Dmytro Podgornyi <dmytrop@nvidia.com>
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.

None yet

1 participant