]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Fix unsigned integer overflow ASAN error for align_diff in crc_folding.c.
authorMika Lindqvist <postmaster@raasu.org>
Sun, 20 Sep 2020 01:25:21 +0000 (18:25 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Thu, 24 Sep 2020 13:43:22 +0000 (15:43 +0200)
  zlib-ng/arch/x86/crc_folding.c:252:31: runtime error: unsigned integer overflow: 0 - 108370614813184 cannot be represented in type 'unsigned long'

arch/x86/crc_folding.c

index 8e32d97b61fcdace9daef53cb6bdb710cbec214e..918bd9468197123fe86c478ff89f48ad5f857c04 100644 (file)
@@ -249,7 +249,7 @@ Z_INTERNAL void crc_fold_copy(deflate_state *const s, unsigned char *dst, const
         goto partial;
     }
 
-    algn_diff = ((uintptr_t)0 - (uintptr_t)src) & 0xF;
+    algn_diff = ((uintptr_t)16 - ((uintptr_t)src & 0xF)) & 0xF;
     if (algn_diff) {
         xmm_crc_part = _mm_loadu_si128((__m128i *)src);
         _mm_storeu_si128((__m128i *)dst, xmm_crc_part);