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

index b6304d730d8cbf571c4113f42d902e416620f2d2..46ea8130196305c2b2eff097526301b51d4f36cc 100644 (file)
@@ -178,7 +178,7 @@ lz_hc_get_matches(struct lz_mf *_mf, struct lz_match matches[])
        u32 hash;
        u32 cur_match;
 
-       if (unlikely(bytes_remaining <= LZ_HC_HASH_BYTES))
+       if (unlikely(bytes_remaining <= mf->base.params.min_match_len))
                goto out;
 
        /* Insert the current position into the appropriate hash chain and set
@@ -263,7 +263,7 @@ lz_hc_skip_position(struct lz_hc *mf)
        const u32 bytes_remaining = lz_mf_get_bytes_remaining(&mf->base);
        u32 hash;
 
-       if (bytes_remaining <= LZ_HC_HASH_BYTES)
+       if (unlikely(bytes_remaining <= mf->base.params.min_match_len))
                goto out;
 
        hash = mf->next_hash;