mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-10-24 04:09:07 +03:00
On macOS, gethostbyname() returns a struct hostent whose h_addr_list array is not aligned for a pointer, so reading h_addr_list[0] as a char * is undefined behavior. Under -fsanitize=undefined with -fno-sanitize-recover, as in the ubsan-mldsa-mlkem pq-all row, build_addr() in wolfssl/test.h aborts the first test that resolves localhost, and unit.test fails. The TLS benchmark client does the same load. glibc aligns the array, so Linux CI does not see it. The library does the same in its gethostbyname() fallbacks, which a build without HAVE_GETADDRINFO uses: wolfIO_TcpConnect() and the OCSP responder screening in wolfIO_OcspDestAllowed(). Configured that way on macOS, both abort under UBSan. Copy the pointer out with XMEMCPY before using it in all four places. A plain assignment would be the same misaligned load; memcpy reads the bytes without an alignment requirement.