From 0d61ea84b52c0d439506f542031530ae6b4b87e2 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Fri, 20 Feb 2026 16:18:38 +0100 Subject: [PATCH 1/2] Fix AF_INET6 accept() address handling --- ixwebsocket/IXSocketServer.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/ixwebsocket/IXSocketServer.cpp b/ixwebsocket/IXSocketServer.cpp index a0d98cff..69303526 100644 --- a/ixwebsocket/IXSocketServer.cpp +++ b/ixwebsocket/IXSocketServer.cpp @@ -308,13 +308,12 @@ namespace ix } // Accept a connection. - // FIXME: Is this working for ipv6 ? - struct sockaddr_in client; // client address information - int clientFd; // socket connected to client - socklen_t addressLen = sizeof(client); - memset(&client, 0, sizeof(client)); + sockaddr_storage clientStorage; // client address information (v4 or v6) + int clientFd; // socket connected to client + socklen_t addressLen = sizeof(clientStorage); + memset(&clientStorage, 0, sizeof(clientStorage)); - if ((clientFd = accept(_serverFd, (struct sockaddr*) &client, &addressLen)) < 0) + if ((clientFd = accept(_serverFd, (struct sockaddr*) &clientStorage, &addressLen)) < 0) { if (!Socket::isWaitNeeded()) { @@ -346,8 +345,10 @@ namespace ix if (_addressFamily == AF_INET) { + auto* client = reinterpret_cast(&clientStorage); + char remoteIp4[INET_ADDRSTRLEN]; - if (ix::inet_ntop(AF_INET, &client.sin_addr, remoteIp4, INET_ADDRSTRLEN) == nullptr) + if (ix::inet_ntop(AF_INET, &client->sin_addr, remoteIp4, INET_ADDRSTRLEN) == nullptr) { int err = Socket::getErrno(); std::stringstream ss; @@ -360,13 +361,15 @@ namespace ix continue; } - remotePort = ix::network_to_host_short(client.sin_port); + remotePort = ix::network_to_host_short(client->sin_port); remoteIp = remoteIp4; } else // AF_INET6 { + auto* client = reinterpret_cast(&clientStorage); + char remoteIp6[INET6_ADDRSTRLEN]; - if (ix::inet_ntop(AF_INET6, &client.sin_addr, remoteIp6, INET6_ADDRSTRLEN) == + if (ix::inet_ntop(AF_INET6, &client->sin6_addr, remoteIp6, INET6_ADDRSTRLEN) == nullptr) { int err = Socket::getErrno(); @@ -380,7 +383,7 @@ namespace ix continue; } - remotePort = ix::network_to_host_short(client.sin_port); + remotePort = ix::network_to_host_short(client->sin6_port); remoteIp = remoteIp6; } From 4eec026be703b16bc2db1795f3a192080362773f Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Fri, 20 Feb 2026 16:29:05 +0100 Subject: [PATCH 2/2] Attempt to pin mbedtls to v3 on mac --- .github/workflows/unittest_mac_tsan_mbedtls.yml | 2 +- makefile.dev | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/unittest_mac_tsan_mbedtls.yml b/.github/workflows/unittest_mac_tsan_mbedtls.yml index ab4d226b..d8e29c1f 100644 --- a/.github/workflows/unittest_mac_tsan_mbedtls.yml +++ b/.github/workflows/unittest_mac_tsan_mbedtls.yml @@ -12,6 +12,6 @@ jobs: - uses: actions/checkout@v1 - uses: seanmiddleditch/gha-setup-ninja@master - name: install mbedtls - run: brew install mbedtls + run: brew install mbedtls@3 - name: make test run: make -f makefile.dev test_tsan_mbedtls diff --git a/makefile.dev b/makefile.dev index f6967e90..eca55859 100644 --- a/makefile.dev +++ b/makefile.dev @@ -129,7 +129,7 @@ test_asan: (cd build ; ctest -V .) test_tsan_mbedtls: - mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_INSTALL_MESSAGE=LAZY -DCMAKE_UNITY_BUILD=ON -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_MBED_TLS=1 -DUSE_TEST=1 .. -DCMAKE_C_FLAGS="-fsanitize=thread -fno-omit-frame-pointer" -DCMAKE_CXX_FLAGS="-fsanitize=thread -fno-omit-frame-pointer") + mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_INSTALL_MESSAGE=LAZY -DCMAKE_UNITY_BUILD=ON -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_MBED_TLS=1 -DUSE_TEST=1 .. -DCMAKE_C_FLAGS="-fsanitize=thread -fno-omit-frame-pointer" -DCMAKE_CXX_FLAGS="-fsanitize=thread -fno-omit-frame-pointer" -DCMAKE_PREFIX_PATH="$(shell brew --prefix mbedtls@3 2>/dev/null || echo /opt/homebrew/opt/mbedtls@3)") (cd build ; ninja) (cd build ; ninja test)