diff options
author | Nikias Bassen | 2024-05-13 19:49:40 +0200 |
---|---|---|
committer | Nikias Bassen | 2024-05-13 19:49:40 +0200 |
commit | 14c2e4b64b2bd6189d06d858bf4898d3a9f5a6e4 (patch) | |
tree | f0a60d84d632cd10ad685c33504e0b5ba74653cb | |
parent | bbf0c65cdeeef3f82d0533d356fd756232c4e4a7 (diff) | |
download | libimobiledevice-glue-14c2e4b64b2bd6189d06d858bf4898d3a9f5a6e4.tar.gz libimobiledevice-glue-14c2e4b64b2bd6189d06d858bf4898d3a9f5a6e4.tar.bz2 |
socket: Create an IPv4 compatible IPv6 socket when NULL is passed to socket_create
-rw-r--r-- | src/socket.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/socket.c b/src/socket.c index d4dedd1..3375e5b 100644 --- a/src/socket.c +++ b/src/socket.c @@ -463,6 +463,7 @@ int socket_create(const char* addr, uint16_t port) { int sfd = -1; int yes = 1; + int no = 0; struct addrinfo hints; struct addrinfo *result, *rp; char portstr[8]; @@ -514,7 +515,7 @@ int socket_create(const char* addr, uint16_t port) #if defined(AF_INET6) && defined(IPV6_V6ONLY) if (rp->ai_family == AF_INET6) { - if (setsockopt(sfd, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&yes, sizeof(int)) == -1) { + if (setsockopt(sfd, IPPROTO_IPV6, IPV6_V6ONLY, (addr) ? (void*)&yes : (void*)&no, sizeof(int)) == -1) { perror("setsockopt() IPV6_V6ONLY"); } } |