From: Joshua Rogers Date: Sat, 11 Oct 2025 06:11:07 +0000 (+0800) Subject: freebsd ktls: avoid unaligned 16 bit length store in ktls_read_record X-Git-Tag: 3.0-PRE-CLANG-FORMAT-WEBKIT~53 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=47b4851d96afedc973941a393a719f4fdf90ce6a;p=thirdparty%2Fopenssl.git freebsd ktls: avoid unaligned 16 bit length store in ktls_read_record This prevents SIGBUS on strict alignment architectures when p+3 is not aligned for 16 bit access. Behavior is unchanged on x86 and matches the Linux path. Signed-off-by: Joshua Rogers Reviewed-by: Matt Caswell Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/28860) (cherry picked from commit c33120d0e403b4079e5104fd20040a51930e8d8e) --- diff --git a/include/internal/ktls.h b/include/internal/ktls.h index e15ac194dcb..06b9c134ba0 100644 --- a/include/internal/ktls.h +++ b/include/internal/ktls.h @@ -174,7 +174,8 @@ static ossl_inline int ktls_read_record(int fd, void *data, size_t length) p[0] = tgr->tls_type; p[1] = tgr->tls_vmajor; p[2] = tgr->tls_vminor; - *(uint16_t *)(p + 3) = htons(ret); + p[3] = (ret >> 8) & 0xff; + p[4] = ret & 0xff; return ret + prepend_length; }