]> wimlib.net Git - wimlib/commitdiff
lz_binary_trees.c: Avoid buffer overrun if min_match_len > 3
authorEric Biggers <ebiggers3@gmail.com>
Sat, 26 Jul 2014 18:46:54 +0000 (13:46 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Sat, 26 Jul 2014 18:46:54 +0000 (13:46 -0500)
src/lz_binary_trees.c

index 98924780fffba1b46c54f4af543fcf3aad253250..be818d72b127f03c4db11aa0854533dd13d49148 100644 (file)
@@ -458,7 +458,7 @@ lz_bt_get_matches(struct lz_mf *_mf, struct lz_match matches[])
        u32 min_len;
        u32 num_matches = 0;
 
        u32 min_len;
        u32 num_matches = 0;
 
-       if (bytes_remaining <= LZ_BT_HASH_BYTES)
+       if (unlikely(bytes_remaining <= mf->base.params.min_match_len + 1))
                goto out;
 
        if (mf->digram_tab) {
                goto out;
 
        if (mf->digram_tab) {
@@ -590,7 +590,7 @@ lz_bt_skip_position(struct lz_bt *mf)
        u32 hash;
        u32 cur_match;
 
        u32 hash;
        u32 cur_match;
 
-       if (bytes_remaining <= LZ_BT_HASH_BYTES)
+       if (unlikely(bytes_remaining <= mf->base.params.min_match_len + 1))
                goto out;
 
        /* Update the digram table.  */
                goto out;
 
        /* Update the digram table.  */