unix: restore skipping of phys_addr copy

Prior to https://github.com/libuv/libuv/pull/1999,
uv_interface_addresses() did not populate the phys_addr field on
Cygwin or MinGW. This commit restores that behavior, which was
mistakenly changed.

Fixes: https://github.com/libuv/libuv/issues/2034
PR-URL: https://github.com/libuv/libuv/pull/2035
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
This commit is contained in:
cjihrig 2018-10-14 11:55:16 -04:00
parent 4b7f368627
commit 69e4af1577
No known key found for this signature in database
GPG Key ID: 7434390BDBE9B9C5
2 changed files with 8 additions and 2 deletions

View File

@ -119,14 +119,19 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
continue;
address = *addresses;
memset(address->phys_addr, 0, sizeof(address->phys_addr));
for (i = 0; i < *count; i++) {
#if defined(__CYGWIN__) || defined(__MSYS__)
memset(address->phys_addr, 0, sizeof(address->phys_addr));
#else
if (strcmp(address->name, ent->ifa_name) == 0) {
struct sockaddr_dl* sa_addr;
sa_addr = (struct sockaddr_dl*)(ent->ifa_addr);
memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr));
} else {
memset(address->phys_addr, 0, sizeof(address->phys_addr));
}
#endif
address++;
}
}

View File

@ -890,12 +890,13 @@ int uv_interface_addresses(uv_interface_address_t** addresses,
continue;
address = *addresses;
memset(address->phys_addr, 0, sizeof(address->phys_addr));
for (i = 0; i < (*count); i++) {
if (strcmp(address->name, ent->ifa_name) == 0) {
sll = (struct sockaddr_ll*)ent->ifa_addr;
memcpy(address->phys_addr, sll->sll_addr, sizeof(address->phys_addr));
} else {
memset(address->phys_addr, 0, sizeof(address->phys_addr));
}
address++;
}