summaryrefslogtreecommitdiffstats
path: root/src/socket.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2024-02-16 12:51:35 +0100
committerGravatar Nikias Bassen2024-02-16 12:51:35 +0100
commit9a2b733732b453c073cdd0e30e405ca84541f8e8 (patch)
tree11e6e99a8a19d807bc2b5d66bf1be822f0ad010a /src/socket.c
parent6d72e57c34002024f49990ed34a5b12a3d81e931 (diff)
downloadlibimobiledevice-glue-9a2b733732b453c073cdd0e30e405ca84541f8e8.tar.gz
libimobiledevice-glue-9a2b733732b453c073cdd0e30e405ca84541f8e8.tar.bz2
socket: Allow NULL as address for socket_create() and socket_connect()
This will connect to localhost without the need to specify localhost or 127.0.0.1 or ::1 and also makes this invulnerable to DNS rebind attacks.
Diffstat (limited to 'src/socket.c')
-rw-r--r--src/socket.c8
1 files changed, 0 insertions, 8 deletions
diff --git a/src/socket.c b/src/socket.c
index f3ea882..6f85f2f 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -432,9 +432,6 @@ int socket_create(const char* addr, uint16_t port)
sprintf(portstr, "%d", port);
- if (!addr) {
- addr = "localhost";
- }
res = getaddrinfo(addr, portstr, &hints, &result);
if (res != 0) {
fprintf(stderr, "%s: getaddrinfo: %s\n", __func__, gai_strerror(res));
@@ -1121,11 +1118,6 @@ int socket_connect(const char *addr, uint16_t port)
int flags = 0;
#endif
- if (!addr) {
- errno = EINVAL;
- return -1;
- }
-
memset(&hints, '\0', sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;