summaryrefslogtreecommitdiffstats
path: root/tools/iproxy.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2020-06-07 02:13:44 +0200
committerGravatar Nikias Bassen2020-06-07 02:13:44 +0200
commit033202c9b1df142139358edec77709aa9ede4f16 (patch)
tree8ded92640594f0e4780feea9441db294ee43b1a3 /tools/iproxy.c
parent95d575a8418b9563a14d61fc500fae36cb0b389a (diff)
downloadlibusbmuxd-033202c9b1df142139358edec77709aa9ede4f16.tar.gz
libusbmuxd-033202c9b1df142139358edec77709aa9ede4f16.tar.bz2
iproxy: Use sockaddr_storage struct in network connection logic
Diffstat (limited to 'tools/iproxy.c')
-rw-r--r--tools/iproxy.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/tools/iproxy.c b/tools/iproxy.c
index 85a215a..d89a01b 100644
--- a/tools/iproxy.c
+++ b/tools/iproxy.c
@@ -124,17 +124,18 @@ static void *acceptor_thread(void *arg)
cdata->sfd = -1;
if (dev->conn_type == CONNECTION_TYPE_NETWORK) {
- unsigned char saddr_[32];
- memset(saddr_, '\0', sizeof(saddr_));
- struct sockaddr* saddr = (struct sockaddr*)&saddr_[0];
+ struct sockaddr_storage saddr_storage;
+ struct sockaddr* saddr = (struct sockaddr*)&saddr_storage;
+
if (((char*)dev->conn_data)[1] == 0x02) { // AF_INET
saddr->sa_family = AF_INET;
- memcpy(&saddr->sa_data[0], (char*)dev->conn_data+2, 14);
+ memcpy(&saddr->sa_data[0], (char*)dev->conn_data + 2, 14);
}
else if (((char*)dev->conn_data)[1] == 0x1E) { //AF_INET6 (bsd)
#ifdef AF_INET6
saddr->sa_family = AF_INET6;
- memcpy(&saddr->sa_data[0], (char*)dev->conn_data+2, 26);
+ /* copy the address and the host dependent scope id */
+ memcpy(&saddr->sa_data[0], (char*)dev->conn_data + 2, 26);
#else
fprintf(stderr, "ERROR: Got an IPv6 address but this system doesn't support IPv6\n");
CDATA_FREE(cdata);