Fix Address Sanitizer findings on GCC117

GCC117 is a Aarch64/ARM64 server with AMD's ARM chip and GCC 7.10. It looks like GCC is performing some std::string optimizations that generates a finding. We did not witness the finding on other platforms, like other Aarch64 devices and x86_64.

We will need to check if taking the address of element-0 is still approved way to get the non-const pointer to the elements
pull/461/head
Jeffrey Walton 2017-08-15 03:11:03 -04:00
parent 0110f8397f
commit 659b47108a
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
1 changed files with 9 additions and 9 deletions

View File

@ -242,13 +242,13 @@ bool TestCompressors()
// Unzip random data. See if we can induce a crash
for (unsigned int i = 0; i<128; i++)
{
SecByteBlock src;
SecByteBlock src;
unsigned int len = GlobalRNG().GenerateWord32(4, 0xfff);
src.resize(len);
src.resize(len);
RandomNumberSource(GlobalRNG(), len, true, new ArraySink(src, src.size()));
src[0] = (byte)0x1f; // magic header
src[1] = (byte)0x8b;
src[1] = (byte)0x8b;
src[2] = 0x00; // extra flags
src[3] = src[3] & (2 | 4 | 8 | 16 | 32); // flags
@ -313,13 +313,13 @@ bool TestCompressors()
// Inflate random data. See if we can induce a crash
for (unsigned int i = 0; i<128; i++)
{
SecByteBlock src;
SecByteBlock src;
unsigned int len = GlobalRNG().GenerateWord32(4, 0xfff);
src.resize(len);
src.resize(len);
RandomNumberSource(GlobalRNG(), len, true, new ArraySink(src, src.size()));
src[0] = (byte)0x1f; // magic header
src[1] = (byte)0x8b;
src[1] = (byte)0x8b;
src[2] = 0x00; // extra flags
src[3] = src[3] & (2 | 4 | 8 | 16 | 32); // flags
@ -392,9 +392,9 @@ bool TestCompressors()
// Decompress random data. See if we can induce a crash
for (unsigned int i = 0; i<128; i++)
{
SecByteBlock src;
SecByteBlock src;
unsigned int len = GlobalRNG().GenerateWord32(4, 0xfff);
src.resize(len);
src.resize(len);
RandomNumberSource(GlobalRNG(), len, true, new ArraySink(src, src.size()));
// CMF byte
@ -536,7 +536,7 @@ bool TestEncryptors()
StringSource(src, true, new LegacyEncryptor(pwd.c_str(),new StringSink(dest)));
StringSource(dest, true, new LegacyDecryptor(pwd.c_str(),new StringSink(rec)));
if (src != rec)
throw Exception(Exception::OTHER_ERROR, "LegacyEncryptor failed a self test");
}