diff options
author | David Benjamin <davidben@google.com> | 2024-06-21 18:21:19 -0400 |
---|---|---|
committer | Boringssl LUCI CQ <boringssl-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2024-06-21 22:39:26 +0000 |
commit | 45db24b36a030ec54464ea7a26c362f3c82305ee (patch) | |
tree | e9543b78b8ef4857e6cf14cf91db26e631507796 /crypto | |
parent | 45b2464158379f48cec6e35a1ef503ddea1511a6 (diff) | |
download | boringssl-45db24b36a030ec54464ea7a26c362f3c82305ee.zip boringssl-45db24b36a030ec54464ea7a26c362f3c82305ee.tar.gz boringssl-45db24b36a030ec54464ea7a26c362f3c82305ee.tar.bz2 |
Work around GCC's broken -Warray-bounds warning
When building with a sufficiently high -march that GCC can use YMM
registers, its -Warray-bounds warning misfires on 32-byte arrays that
are initialized directly. See
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114826
Work around this by using a less safe pattern and initializing the array
with memset.
Change-Id: I3bcbdca2b749fd7a3093d5194515a04c034e7bf9
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/69567
Reviewed-by: Adam Langley <agl@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/curve25519/x25519_test.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/crypto/curve25519/x25519_test.cc b/crypto/curve25519/x25519_test.cc index c1b9e40..20472df 100644 --- a/crypto/curve25519/x25519_test.cc +++ b/crypto/curve25519/x25519_test.cc @@ -158,7 +158,13 @@ TEST(X25519Test, SmallOrder) { TEST(X25519Test, Iterated) { // Taken from https://tools.ietf.org/html/rfc7748#section-5.2. - uint8_t scalar[32] = {9}, point[32] = {9}, out[32]; + uint8_t scalar[32], point[32], out[32]; + // This could simply be `uint8_t scalar[32] = {9}`, but GCC's -Warray-bounds + // warning is broken. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114826. + OPENSSL_memset(scalar, 0, sizeof(scalar)); + scalar[0] = 9; + OPENSSL_memset(point, 0, sizeof(point)); + point[0] = 9; for (unsigned i = 0; i < 1000; i++) { EXPECT_TRUE(ctwrapX25519(out, scalar, point)); @@ -177,7 +183,13 @@ TEST(X25519Test, Iterated) { TEST(X25519Test, DISABLED_IteratedLarge) { // Taken from https://tools.ietf.org/html/rfc7748#section-5.2. - uint8_t scalar[32] = {9}, point[32] = {9}, out[32]; + uint8_t scalar[32], point[32], out[32]; + // This could simply be `uint8_t scalar[32] = {9}`, but GCC's -Warray-bounds + // warning is broken. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114826. + OPENSSL_memset(scalar, 0, sizeof(scalar)); + scalar[0] = 9; + OPENSSL_memset(point, 0, sizeof(point)); + point[0] = 9; for (unsigned i = 0; i < 1000000; i++) { EXPECT_TRUE(ctwrapX25519(out, scalar, point)); |