mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-20 21:43:41 +00:00
find_library's search order puts CMAKE_PREFIX_PATH ahead of HINTS, so on a Homebrew machine with both mbedtls (4.x) and the keg-only mbedtls@3, the headers resolved to mbedtls@3 while the libraries resolved to 4.x. That is not a link error but memory corruption at runtime: mbedtls_cipher_context_t grew between the two versions, so every context allocated with ss_malloc(sizeof(cipher_evp_t)) from the 3.x headers was overrun by 4.x's mbedtls_cipher_init. It corrupted the heap in every binary that sets up a cipher, and made the unit tests segfault inside an unrelated malloc. Pick a prefix that provides both the headers and libmbedcrypto and pin every component to it, then verify at configure time that the header version string matches what the linked library reports, so a mismatch fails the build instead of corrupting memory.