:: commit 6bd5aa22e17069d44803394cba141e382b7e9cf2

Kamila Szewczyk <kspalaiologos@gmail.com> — 2022-07-31 14:45

parents: d861c34786

misc e8e9 fixes. still not satisfactory :(

diff --git a/src/e8e9.c b/src/e8e9.c
index 14a3aa7..9caa972 100644
--- a/src/e8e9.c
+++ b/src/e8e9.c
@@ -115,9 +115,9 @@ s32 e8e9_forward(u8 * restrict in, s32 inlen, u8 * restrict out) {
 
     struct e8e9 s = e8e9_init();
 
-    /* All of the octets should be less than 2% of the data. */
+    /* All of the octets should be less than 2% of the data and more than 0.5% of the data. */
     s32 p = oct * 1000 / inlen;
-    if(p < 20) {
+    if(p < 20 && p > 10) {
         for(s32 i = 0; i < inlen; i++) {
             int c = e8e9_fb(&s, in[i]);
             if (c >= 0) out[out_ptr++] = c;
diff --git a/src/libbz3.c b/src/libbz3.c
index edbdbb5..56a4f19 100644
--- a/src/libbz3.c
+++ b/src/libbz3.c
@@ -233,7 +233,8 @@ PUBLIC_API s32 bz3_decode_block(struct bz3_state * state, u8 * buffer, s32 data_
     data_size -= p * 4 + 1;
 
     if (((model & 2) && (lzp_size > state->block_size + state->block_size / 50 + 32 || lzp_size < 0)) ||
-        ((model & 4) && (rle_size > state->block_size + state->block_size / 50 + 32 || rle_size < 0))) {
+        ((model & 4) && (rle_size > state->block_size + state->block_size / 50 + 32 || rle_size < 0)) ||
+        ((model & 8) && (e8e9_size > state->block_size + state->block_size / 50 + 32 || e8e9_size < 0))) {
         state->last_error = BZ3_ERR_MALFORMED_HEADER;
         return -1;
     }
@@ -243,11 +244,6 @@ PUBLIC_API s32 bz3_decode_block(struct bz3_state * state, u8 * buffer, s32 data_
         return -1;
     }
 
-    if (e8e9_size > state->block_size + state->block_size / 50 + 32 || e8e9_size < 0) {
-        state->last_error = BZ3_ERR_MALFORMED_HEADER;
-        return -1;
-    }
-
     // Decode the data.
     u8 *b1 = buffer, *b2 = state->swap_buffer;
 
tab: 248 wrap: offon