From: Vsevolod Stakhov Date: Wed, 25 Sep 2019 12:59:19 +0000 (+0100) Subject: [Minor] Avoid out-of-boundary read in btrie X-Git-Tag: 2.0~130 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6f927c7c623f24684ed917c1a0afc89b0d2b77cb;p=rspamd.git [Minor] Avoid out-of-boundary read in btrie Submitted by: @citrin --- diff --git a/contrib/lc-btrie/btrie.c b/contrib/lc-btrie/btrie.c index b1c66f1c3..8b598b09b 100644 --- a/contrib/lc-btrie/btrie.c +++ b/contrib/lc-btrie/btrie.c @@ -658,7 +658,8 @@ static inline int prefixes_equal(const btrie_oct_t *pfx1, const btrie_oct_t *pfx2, unsigned len) { return (memcmp (pfx1, pfx2, len / 8) == 0 - && ((pfx1[len / 8] ^ pfx2[len / 8]) & high_bits (len % 8)) == 0); + && (len % 8 == 0 || + ((pfx1[len / 8] ^ pfx2[len / 8]) & high_bits (len % 8)) == 0)); } /* determine length of longest common subprefix */