mirror of
https://github.com/openssl/openssl.git
synced 2026-06-06 20:18:09 +00:00
typed safestack wrappers pass type-specific copy callbacks such as TYPE *(*)(const TYPE *) to OPENSSL_sk_deep_copy(). The generic stack code then called those callbacks through OPENSSL_sk_copyfunc, void *(*)(const void *), which is an incompatible function pointer type and triggers UBSan. Add an OPENSSL_sk_copyfunc_thunk and store it on typed stacks, mirroring the existing compare/free thunk pattern. Generated safestack helpers now install a per-type copy thunk when constructing a stack, and internal_copy() uses that thunk when deep-copying typed stacks. This preserves the generic stack API while ensuring typed copy callbacks are invoked through their real signature. Fixes: https://github.com/openssl/project/issues/1951 Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org> Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org> Reviewed-by: Neil Horman <nhorman@openssl.org> MergeDate: Wed May 20 15:53:45 2026 (Merged from https://github.com/openssl/openssl/pull/31151)