:: commit c7559a5a8b99626abfff80d622d984038f233396

Kamila Szewczyk <kspalaiologos@gmail.com> — 2023-01-13 09:43

parents: 1feebd009e

enlargen the SAIS buffer beyond the documented required size ...

to try mitigating some invalid reads in the library.
diff --git a/src/libbz3.c b/src/libbz3.c
index 66a3ca1..3a4bc0f 100644
--- a/src/libbz3.c
+++ b/src/libbz3.c
@@ -497,8 +497,8 @@ BZIP3_API struct bz3_state * bz3_new(s32 block_size) {
     bz3_state->cm_state = malloc(sizeof(state));
 
     bz3_state->swap_buffer = malloc(bz3_bound(block_size));
-    bz3_state->sais_array = malloc((block_size + 2) * sizeof(s32));
-    memset(bz3_state->sais_array, 0, sizeof(s32) * (block_size + 2));
+    bz3_state->sais_array = malloc((block_size + 128) * sizeof(s32));
+    memset(bz3_state->sais_array, 0, sizeof(s32) * (block_size + 128));
 
     bz3_state->lzp_lut = calloc(1 << LZP_DICTIONARY, sizeof(s32));
 
tab: 248 wrap: offon