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 elementspull/461/head
parent
0110f8397f
commit
659b47108a
18
validat0.cpp
18
validat0.cpp
|
|
@ -242,13 +242,13 @@ bool TestCompressors()
|
||||||
// Unzip random data. See if we can induce a crash
|
// Unzip random data. See if we can induce a crash
|
||||||
for (unsigned int i = 0; i<128; i++)
|
for (unsigned int i = 0; i<128; i++)
|
||||||
{
|
{
|
||||||
SecByteBlock src;
|
SecByteBlock src;
|
||||||
unsigned int len = GlobalRNG().GenerateWord32(4, 0xfff);
|
unsigned int len = GlobalRNG().GenerateWord32(4, 0xfff);
|
||||||
src.resize(len);
|
src.resize(len);
|
||||||
RandomNumberSource(GlobalRNG(), len, true, new ArraySink(src, src.size()));
|
RandomNumberSource(GlobalRNG(), len, true, new ArraySink(src, src.size()));
|
||||||
|
|
||||||
src[0] = (byte)0x1f; // magic header
|
src[0] = (byte)0x1f; // magic header
|
||||||
src[1] = (byte)0x8b;
|
src[1] = (byte)0x8b;
|
||||||
src[2] = 0x00; // extra flags
|
src[2] = 0x00; // extra flags
|
||||||
src[3] = src[3] & (2 | 4 | 8 | 16 | 32); // 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
|
// Inflate random data. See if we can induce a crash
|
||||||
for (unsigned int i = 0; i<128; i++)
|
for (unsigned int i = 0; i<128; i++)
|
||||||
{
|
{
|
||||||
SecByteBlock src;
|
SecByteBlock src;
|
||||||
unsigned int len = GlobalRNG().GenerateWord32(4, 0xfff);
|
unsigned int len = GlobalRNG().GenerateWord32(4, 0xfff);
|
||||||
src.resize(len);
|
src.resize(len);
|
||||||
RandomNumberSource(GlobalRNG(), len, true, new ArraySink(src, src.size()));
|
RandomNumberSource(GlobalRNG(), len, true, new ArraySink(src, src.size()));
|
||||||
|
|
||||||
src[0] = (byte)0x1f; // magic header
|
src[0] = (byte)0x1f; // magic header
|
||||||
src[1] = (byte)0x8b;
|
src[1] = (byte)0x8b;
|
||||||
src[2] = 0x00; // extra flags
|
src[2] = 0x00; // extra flags
|
||||||
src[3] = src[3] & (2 | 4 | 8 | 16 | 32); // 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
|
// Decompress random data. See if we can induce a crash
|
||||||
for (unsigned int i = 0; i<128; i++)
|
for (unsigned int i = 0; i<128; i++)
|
||||||
{
|
{
|
||||||
SecByteBlock src;
|
SecByteBlock src;
|
||||||
unsigned int len = GlobalRNG().GenerateWord32(4, 0xfff);
|
unsigned int len = GlobalRNG().GenerateWord32(4, 0xfff);
|
||||||
src.resize(len);
|
src.resize(len);
|
||||||
RandomNumberSource(GlobalRNG(), len, true, new ArraySink(src, src.size()));
|
RandomNumberSource(GlobalRNG(), len, true, new ArraySink(src, src.size()));
|
||||||
|
|
||||||
// CMF byte
|
// CMF byte
|
||||||
|
|
@ -536,7 +536,7 @@ bool TestEncryptors()
|
||||||
|
|
||||||
StringSource(src, true, new LegacyEncryptor(pwd.c_str(),new StringSink(dest)));
|
StringSource(src, true, new LegacyEncryptor(pwd.c_str(),new StringSink(dest)));
|
||||||
StringSource(dest, true, new LegacyDecryptor(pwd.c_str(),new StringSink(rec)));
|
StringSource(dest, true, new LegacyDecryptor(pwd.c_str(),new StringSink(rec)));
|
||||||
|
|
||||||
if (src != rec)
|
if (src != rec)
|
||||||
throw Exception(Exception::OTHER_ERROR, "LegacyEncryptor failed a self test");
|
throw Exception(Exception::OTHER_ERROR, "LegacyEncryptor failed a self test");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue