summaryrefslogtreecommitdiff
path: root/deps/uv/src/unix/aix-common.c
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2019-12-03 22:19:16 -0500
committercjihrig <cjihrig@gmail.com>2019-12-06 11:14:59 -0500
commit5d2944d7b65840766bd8c4efef0af4e2680c0166 (patch)
tree76d1bd0017ca8667aeb34767fec599cdf414121d /deps/uv/src/unix/aix-common.c
parent09ea00b0c117d219ec7017e7125601e9e26f84b9 (diff)
downloadandroid-node-v8-5d2944d7b65840766bd8c4efef0af4e2680c0166.tar.gz
android-node-v8-5d2944d7b65840766bd8c4efef0af4e2680c0166.tar.bz2
android-node-v8-5d2944d7b65840766bd8c4efef0af4e2680c0166.zip
deps: upgrade to libuv 1.34.0
Notable changes: - Fix handling of large files in uv_fs_copyfile(). Fixes: https://github.com/nodejs/node/issues/30085 - Fix Android build errors. - uv_sleep() has been added. - uv_interface_addresses() IPv6 netmask support has been fixed. Fixes: https://github.com/nodejs/node/issues/30504 - uv_fs_mkstemp() has been added. PR-URL: https://github.com/nodejs/node/pull/30783 Fixes: https://github.com/nodejs/node/issues/30085 Fixes: https://github.com/nodejs/node/issues/30504 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'deps/uv/src/unix/aix-common.c')
-rw-r--r--deps/uv/src/unix/aix-common.c114
1 files changed, 82 insertions, 32 deletions
diff --git a/deps/uv/src/unix/aix-common.c b/deps/uv/src/unix/aix-common.c
index b9d313c0c5..e96e34c463 100644
--- a/deps/uv/src/unix/aix-common.c
+++ b/deps/uv/src/unix/aix-common.c
@@ -34,6 +34,7 @@
#include <sys/ioctl.h>
#include <net/if.h>
#include <netinet/in.h>
+#include <netinet/in6_var.h>
#include <arpa/inet.h>
#include <sys/time.h>
@@ -158,28 +159,42 @@ int uv_exepath(char* buffer, size_t* size) {
int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
uv_interface_address_t* address;
- int sockfd, inet6, size = 1;
+ int sockfd, sock6fd, inet6, i, r, size = 1;
struct ifconf ifc;
struct ifreq *ifr, *p, flg;
+ struct in6_ifreq if6;
struct sockaddr_dl* sa_addr;
+ ifc.ifc_req = NULL;
+ sock6fd = -1;
+ r = 0;
*count = 0;
*addresses = NULL;
if (0 > (sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP))) {
- return UV__ERR(errno);
+ r = UV__ERR(errno);
+ goto cleanup;
+ }
+
+ if (0 > (sock6fd = socket(AF_INET6, SOCK_DGRAM, IPPROTO_IP))) {
+ r = UV__ERR(errno);
+ goto cleanup;
}
if (ioctl(sockfd, SIOCGSIZIFCONF, &size) == -1) {
- uv__close(sockfd);
- return UV__ERR(errno);
+ r = UV__ERR(errno);
+ goto cleanup;
}
ifc.ifc_req = (struct ifreq*)uv__malloc(size);
+ if (ifc.ifc_req == NULL) {
+ r = UV_ENOMEM;
+ goto cleanup;
+ }
ifc.ifc_len = size;
if (ioctl(sockfd, SIOCGIFCONF, &ifc) == -1) {
- uv__close(sockfd);
- return UV__ERR(errno);
+ r = UV__ERR(errno);
+ goto cleanup;
}
#define ADDR_SIZE(p) MAX((p).sa_len, sizeof(p))
@@ -197,8 +212,8 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name));
if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) {
- uv__close(sockfd);
- return UV__ERR(errno);
+ r = UV__ERR(errno);
+ goto cleanup;
}
if (!(flg.ifr_flags & IFF_UP && flg.ifr_flags & IFF_RUNNING))
@@ -207,16 +222,14 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
(*count)++;
}
- if (*count == 0) {
- uv__close(sockfd);
- return 0;
- }
+ if (*count == 0)
+ goto cleanup;
/* Alloc the return interface structs */
- *addresses = uv__malloc(*count * sizeof(uv_interface_address_t));
+ *addresses = uv__calloc(*count, sizeof(**addresses));
if (!(*addresses)) {
- uv__close(sockfd);
- return UV_ENOMEM;
+ r = UV_ENOMEM;
+ goto cleanup;
}
address = *addresses;
@@ -233,10 +246,8 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
inet6 = (p->ifr_addr.sa_family == AF_INET6);
memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name));
- if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) {
- uv__close(sockfd);
- return UV_ENOSYS;
- }
+ if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1)
+ goto syserror;
if (!(flg.ifr_flags & IFF_UP && flg.ifr_flags & IFF_RUNNING))
continue;
@@ -250,28 +261,67 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
else
address->address.address4 = *((struct sockaddr_in*) &p->ifr_addr);
- sa_addr = (struct sockaddr_dl*) &p->ifr_addr;
- memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr));
-
- if (ioctl(sockfd, SIOCGIFNETMASK, p) == -1) {
- uv__close(sockfd);
- return UV_ENOSYS;
- }
-
- if (inet6)
- address->netmask.netmask6 = *((struct sockaddr_in6*) &p->ifr_addr);
- else
+ if (inet6) {
+ memset(&if6, 0, sizeof(if6));
+ r = uv__strscpy(if6.ifr_name, p->ifr_name, sizeof(if6.ifr_name));
+ if (r == UV_E2BIG)
+ goto cleanup;
+ r = 0;
+ memcpy(&if6.ifr_Addr, &p->ifr_addr, sizeof(if6.ifr_Addr));
+ if (ioctl(sock6fd, SIOCGIFNETMASK6, &if6) == -1)
+ goto syserror;
+ address->netmask.netmask6 = *((struct sockaddr_in6*) &if6.ifr_Addr);
+ /* Explicitly set family as the ioctl call appears to return it as 0. */
+ address->netmask.netmask6.sin6_family = AF_INET6;
+ } else {
+ if (ioctl(sockfd, SIOCGIFNETMASK, p) == -1)
+ goto syserror;
address->netmask.netmask4 = *((struct sockaddr_in*) &p->ifr_addr);
+ /* Explicitly set family as the ioctl call appears to return it as 0. */
+ address->netmask.netmask4.sin_family = AF_INET;
+ }
address->is_internal = flg.ifr_flags & IFF_LOOPBACK ? 1 : 0;
address++;
}
+ /* Fill in physical addresses. */
+ ifr = ifc.ifc_req;
+ while ((char*)ifr < (char*)ifc.ifc_req + ifc.ifc_len) {
+ p = ifr;
+ ifr = (struct ifreq*)
+ ((char*)ifr + sizeof(ifr->ifr_name) + ADDR_SIZE(ifr->ifr_addr));
+
+ if (p->ifr_addr.sa_family != AF_LINK)
+ continue;
+
+ address = *addresses;
+ for (i = 0; i < *count; i++) {
+ if (strcmp(address->name, p->ifr_name) == 0) {
+ sa_addr = (struct sockaddr_dl*) &p->ifr_addr;
+ memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr));
+ }
+ address++;
+ }
+ }
+
#undef ADDR_SIZE
+ goto cleanup;
- uv__close(sockfd);
- return 0;
+syserror:
+ uv_free_interface_addresses(*addresses, *count);
+ *addresses = NULL;
+ *count = 0;
+ r = UV_ENOSYS;
+
+cleanup:
+ if (sockfd != -1)
+ uv__close(sockfd);
+ if (sock6fd != -1)
+ uv__close(sock6fd);
+ uv__free(ifc.ifc_req);
+ return r;
}