aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/lc-btrie/btrie.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-09-25 13:59:19 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-09-25 13:59:19 +0100
commit6f927c7c623f24684ed917c1a0afc89b0d2b77cb (patch)
tree2a1f64145af9b2c2c42451a998f3c93dc84dd79d /contrib/lc-btrie/btrie.c
parent8cd410a8caf15016f3edecb00a67d3c6f0dfa584 (diff)
downloadrspamd-6f927c7c623f24684ed917c1a0afc89b0d2b77cb.tar.gz
rspamd-6f927c7c623f24684ed917c1a0afc89b0d2b77cb.zip
[Minor] Avoid out-of-boundary read in btrie
Submitted by: @citrin
Diffstat (limited to 'contrib/lc-btrie/btrie.c')
-rw-r--r--contrib/lc-btrie/btrie.c3
1 files changed, 2 insertions, 1 deletions
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 */