LibCrypto: Add workaround for false -Warray-bounds warning

When building for AArch64 with UBSan enabled, GCC 13.1 reports a false
"array out of bounds" error on access to offset `1 * sizeof(u64)`.
Changing the order of the stores seems to silence it.
This commit is contained in:
Daniel Bertalan 2023-05-27 00:11:30 +02:00 committed by Andrew Kaster
parent 6bcd73a2ff
commit 12a2f741a7
Notes: sideshowbarker 2024-07-17 03:27:40 +09:00

View file

@ -40,10 +40,10 @@ static void export_big_endian(u256 const& value, Bytes data)
u64 c = AK::convert_between_host_and_big_endian(value.high().low());
u64 d = AK::convert_between_host_and_big_endian(value.high().high());
ByteReader::store(data.offset_pointer(0 * sizeof(u64)), d);
ByteReader::store(data.offset_pointer(1 * sizeof(u64)), c);
ByteReader::store(data.offset_pointer(2 * sizeof(u64)), b);
ByteReader::store(data.offset_pointer(3 * sizeof(u64)), a);
ByteReader::store(data.offset_pointer(2 * sizeof(u64)), b);
ByteReader::store(data.offset_pointer(1 * sizeof(u64)), c);
ByteReader::store(data.offset_pointer(0 * sizeof(u64)), d);
}
static u256 select(u256 const& left, u256 const& right, bool condition)