diff options
author | Emilian Peev <epeev@google.com> | 2018-12-28 10:07:46 +0000 |
---|---|---|
committer | Emilian Peev <epeev@google.com> | 2018-12-28 10:07:46 +0000 |
commit | ec731c6e0af9d28d4bbb87f5ffc6ac3ee9c01852 (patch) | |
tree | 0435aa9eae20727828bd97bf7ca9b03d12424a84 | |
parent | 7ea165eee5d01e4cd8b99ebc2aae20d802615f5a (diff) | |
download | dynamic_depth-ec731c6e0af9d28d4bbb87f5ffc6ac3ee9c01852.tar.gz |
Disable unsigned overflow sanitizer during MD5 transformation
It seems unsigned overflows during MD5 calculations are
possible. Disable the undefined behavior sanitization
for this particular case.
Bug: 109735087
Test: Manual using application
Change-Id: Ibbec9a5d38f8713de254ac2e26438992cf0da9f2
-rw-r--r-- | internal/xmpmeta/md5.cc | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/internal/xmpmeta/md5.cc b/internal/xmpmeta/md5.cc index 008ff7a..8c44267 100644 --- a/internal/xmpmeta/md5.cc +++ b/internal/xmpmeta/md5.cc @@ -120,10 +120,21 @@ void MD5Final(uint8 digest[16], MD5Context* ctx) { #define MD5STEP(f, w, x, y, z, data, s) \ (w += f(x, y, z) + data, w = w << s | w >> (32 - s), w += x) +#if defined(__clang__) && defined(__has_attribute) +#if __has_attribute(no_sanitize) +#define DDEPTH_NO_UNSIGNED_OVERFLOW_CHECK \ + __attribute__((no_sanitize("unsigned-integer-overflow"))) +#endif +#endif + +#ifndef DDEPTH_NO_UNSIGNED_OVERFLOW_CHECK +#define DDEPTH_NO_UNSIGNED_OVERFLOW_CHECK +#endif + // The core of the MD5 algorithm, this alters an existing MD5 hash to // reflect the addition of 16 longwords of new data. MD5Update blocks // the data and converts bytes into longwords for this routine. -void MD5Transform(uint32 buf[4], const uint32 in[16]) { +DDEPTH_NO_UNSIGNED_OVERFLOW_CHECK void MD5Transform(uint32 buf[4], const uint32 in[16]) { uint32 a = buf[0]; uint32 b = buf[1]; uint32 c = buf[2]; |