]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Bug fix redzones by unpoisoning only the intended buffer and not the followup redzone. 3451/head
authorYonatan Komornik <yoniko@gmail.com>
Tue, 24 Jan 2023 20:54:43 +0000 (12:54 -0800)
committerYonatan Komornik <yoniko@gmail.com>
Tue, 24 Jan 2023 20:54:43 +0000 (12:54 -0800)
lib/compress/zstd_cwksp.h

index 70a359a2707643292d1c5b68252b1e9657c21529..97676693b5eed10b306e1eaa05f3bd3744e95aa6 100644 (file)
@@ -348,7 +348,9 @@ ZSTD_cwksp_reserve_internal(ZSTD_cwksp* ws, size_t bytes, ZSTD_cwksp_alloc_phase
     if (alloc) {
         alloc = (BYTE *)alloc + ZSTD_CWKSP_ASAN_REDZONE_SIZE;
         if (ws->isStatic == ZSTD_cwksp_dynamic_alloc) {
-            __asan_unpoison_memory_region(alloc, bytes);
+            /* We need to keep the redzone poisoned while unpoisoning the bytes that
+             * are actually allocated. */
+            __asan_unpoison_memory_region(alloc, bytes - 2 * ZSTD_CWKSP_ASAN_REDZONE_SIZE);
         }
     }
 #endif