commit 6f927c7: [Minor] Avoid out-of-boundary read in btrie

Vsevolod Stakhov vsevolod at highsecure.ru
Wed Sep 25 13:00:06 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-09-25 13:59:19 +0100
URL: https://github.com/rspamd/rspamd/commit/6f927c7c623f24684ed917c1a0afc89b0d2b77cb (HEAD -> master)

[Minor] Avoid out-of-boundary read in btrie
Submitted by: @citrin

---
 contrib/lc-btrie/btrie.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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 */


More information about the Commits mailing list