diff options
author | Eugene Kliuchnikov <eustas@google.com> | 2018-09-13 08:09:32 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-13 08:09:32 -0400 |
commit | 2216a0dd63e0142b78abe97bba8be52f6bc972c7 (patch) | |
tree | 22ea063e1811526674cb9b01ff60b9a47bd4ef93 /c/common | |
parent | d4cd6cdf1cd52b75f871b6d75b1c8941454371db (diff) | |
download | brotli-2216a0dd63e0142b78abe97bba8be52f6bc972c7.zip brotli-2216a0dd63e0142b78abe97bba8be52f6bc972c7.tar.gz brotli-2216a0dd63e0142b78abe97bba8be52f6bc972c7.tar.bz2 |
Update (#706)
Update
* add ASAN/MSAN unaligned read specializations
* add "brotli" prefix to u_uint64 type
* increment version to 1.0.06
* fix CoverityScan "unused assignment" warning
* fix JDK 8<->9 incompatibility
* add encoder optimization for empty input
* regenerate JS decoder
* unbreak Travis builds
Diffstat (limited to 'c/common')
-rwxr-xr-x | c/common/platform.h | 36 | ||||
-rw-r--r-- | c/common/version.h | 4 |
2 files changed, 34 insertions, 6 deletions
diff --git a/c/common/platform.h b/c/common/platform.h index 7f3ce5f..0d84b19 100755 --- a/c/common/platform.h +++ b/c/common/platform.h @@ -298,6 +298,33 @@ static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) { } #else /* BROTLI_ALIGNED_READ */ /* Unaligned memory access is allowed: just cast pointer to requested type. */ +#if defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER) || \ + defined(MEMORY_SANITIZER) +/* Consider we have an unaligned load/store of 4 bytes from address 0x...05. + AddressSanitizer will treat it as a 3-byte access to the range 05:07 and + will miss a bug if 08 is the first unaddressable byte. + ThreadSanitizer will also treat this as a 3-byte access to 05:07 and will + miss a race between this access and some other accesses to 08. + MemorySanitizer will correctly propagate the shadow on unaligned stores + and correctly report bugs on unaligned loads, but it may not properly + update and report the origin of the uninitialized memory. + For all three tools, replacing an unaligned access with a tool-specific + callback solves the problem. */ +#if defined(__cplusplus) +extern "C" { +#endif /* __cplusplus */ + uint16_t __sanitizer_unaligned_load16(const void* p); + uint32_t __sanitizer_unaligned_load32(const void* p); + uint64_t __sanitizer_unaligned_load64(const void* p); + void __sanitizer_unaligned_store64(void* p, uint64_t v); +#if defined(__cplusplus) +} /* extern "C" */ +#endif /* __cplusplus */ +#define BrotliUnalignedRead16 __sanitizer_unaligned_load16 +#define BrotliUnalignedRead32 __sanitizer_unaligned_load32 +#define BrotliUnalignedRead64 __sanitizer_unaligned_load64 +#define BrotliUnalignedWrite64 __sanitizer_unaligned_store64 +#else static BROTLI_INLINE uint16_t BrotliUnalignedRead16(const void* p) { return *(const uint16_t*)p; } @@ -316,14 +343,14 @@ static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) { /* If __attribute__(aligned) is available, use that. Otherwise, memcpy. */ #if BROTLI_GNUC_HAS_ATTRIBUTE(aligned, 2, 7, 0) -typedef __attribute__((aligned(1))) uint64_t unaligned_uint64_t; +typedef __attribute__((aligned(1))) uint64_t brotli_unaligned_uint64_t; static BROTLI_INLINE uint64_t BrotliUnalignedRead64(const void* p) { - return (uint64_t) ((unaligned_uint64_t*) p)[0]; + return (uint64_t) ((brotli_unaligned_uint64_t*) p)[0]; } static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) { - unaligned_uint64_t* dwords = (unaligned_uint64_t*) p; - dwords[0] = (unaligned_uint64_t) v; + brotli_unaligned_uint64_t* dwords = (brotli_unaligned_uint64_t*) p; + dwords[0] = (brotli_unaligned_uint64_t) v; } #else /* BROTLI_GNUC_HAS_ATTRIBUTE(aligned, 2, 7, 0) */ static BROTLI_INLINE uint64_t BrotliUnalignedRead64(const void* p) { @@ -337,6 +364,7 @@ static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) { } #endif /* BROTLI_GNUC_HAS_ATTRIBUTE(aligned, 2, 7, 0) */ #endif /* BROTLI_64_BITS */ +#endif /* ASAN / TSAN / MSAN */ #endif /* BROTLI_ALIGNED_READ */ #if BROTLI_LITTLE_ENDIAN diff --git a/c/common/version.h b/c/common/version.h index f787d06..1ba0806 100644 --- a/c/common/version.h +++ b/c/common/version.h @@ -14,13 +14,13 @@ BrotliEncoderVersion methods. */ /* Semantic version, calculated as (MAJOR << 24) | (MINOR << 12) | PATCH */ -#define BROTLI_VERSION 0x1000005 +#define BROTLI_VERSION 0x1000006 /* This macro is used by build system to produce Libtool-friendly soname. See https://www.gnu.org/software/libtool/manual/html_node/Libtool-versioning.html */ /* ABI version, calculated as (CURRENT << 24) | (REVISION << 12) | AGE */ -#define BROTLI_ABI_VERSION 0x1005000 +#define BROTLI_ABI_VERSION 0x1006000 #endif /* BROTLI_COMMON_VERSION_H_ */ |