Commit e8e491b
Filter local interface DNS results by address family (#128705)
> [!NOTE]
> This PR description was generated with GitHub Copilot.
Fixes #128371
`SystemNative_GetHostEntryForName` already passes the requested address
family to `getaddrinfo` through `hint.ai_family`. However, when the
queried name matches the value returned by `gethostname()`, the PAL
augments those resolver results with local interface addresses from
`getifaddrs`. That augmentation path was not applying the same
address-family filter, so an IPv4-only lookup could still append IPv6
interface addresses, and vice versa.
This became observable on Android after the minimum API level was raised
from 21 to 24. Android API 24 exposes Bionic `getifaddrs`, so
`HAVE_GETIFADDRS` is now true for Android native builds and this
local-interface augmentation can run there. The failing CI pattern
points specifically at Windows-hosted physical Android device lanes:
those devices appear to enter the local-hostname augmentation path for
`localhost`, while Ubuntu emulator lanes and a local Samsung physical
device did not.
The fix filters `getifaddrs` entries by the requested platform family in
both the counting and population passes. Requests with `AF_UNSPEC` are
intentionally left unchanged, so default/unspecified lookups can
continue returning both IPv4 and IPv6 addresses as before.
I considered making this Android-specific or filtering in managed code,
but the mismatch is in the native PAL contract: callers pass an address
family into `SystemNative_GetHostEntryForName`, `getaddrinfo` honors it,
and only the native `getifaddrs` augmentation ignores it. Keeping the
fix in native makes the whole returned `HostEntry` internally consistent
across platforms. The behavioral impact on non-Android Unix platforms
should be limited to local-hostname lookups that explicitly request IPv4
or IPv6; those calls should not receive opposite-family interface
addresses.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent a72c2a3 commit e8e491b
1 file changed
Lines changed: 17 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
452 | 452 | | |
453 | 453 | | |
454 | 454 | | |
455 | | - | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
456 | 462 | | |
457 | 463 | | |
458 | 464 | | |
| |||
462 | 468 | | |
463 | 469 | | |
464 | 470 | | |
465 | | - | |
| 471 | + | |
466 | 472 | | |
467 | 473 | | |
468 | 474 | | |
| |||
512 | 518 | | |
513 | 519 | | |
514 | 520 | | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
515 | 527 | | |
516 | | - | |
517 | | - | |
| 528 | + | |
| 529 | + | |
518 | 530 | | |
519 | 531 | | |
520 | 532 | | |
521 | 533 | | |
522 | 534 | | |
523 | | - | |
| 535 | + | |
524 | 536 | | |
525 | 537 | | |
526 | 538 | | |
| |||
0 commit comments