diff options
author | kenjiro <> | 2025-07-17 00:55:48 +0000 |
---|---|---|
committer | kenjiro <> | 2025-07-17 00:55:48 +0000 |
commit | ab69829b1842069afe7d1706fc0a2f3fc3b3afdb (patch) | |
tree | 406b1b3531c309d7d0efb18765105366f6728880 /src/lib/libc/string | |
parent | 8f50017b2f3140559d3ec2be8f894f8573d45e7f (diff) | |
download | openbsd-ab69829b1842069afe7d1706fc0a2f3fc3b3afdb.tar.gz openbsd-ab69829b1842069afe7d1706fc0a2f3fc3b3afdb.tar.bz2 openbsd-ab69829b1842069afe7d1706fc0a2f3fc3b3afdb.zip |
avoid undefined behavior when shifting into sign bit
Shifting a signed int64_t into the sign bit is undefined behavior in C.
/dev/portable/crypto/curve25519/curve25519.c:3900:18: runtime error:
left shift of negative value -222076011
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /dev/portable
To avoid this, import int64_lshift21() from BoringSSL, a helper function
that casts the input to uint64_t before shifting and back to int64_t afterward.
This ensures defined behavior when shifting left by 21 bits, avoiding
undefined behavior in expressions like `carry << 21`.
This change addresses potential runtime issues detected by sanitizers
when shifting signed values with high bits set.
ok tb beck
Diffstat (limited to 'src/lib/libc/string')
0 files changed, 0 insertions, 0 deletions