From 6f1d2064568e8bd3840cd6300608f22c75c4ea80 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 4 Apr 2017 14:40:13 +0100 Subject: [PATCH] [Minor] Fix out-of-bound read --- src/libutil/shingles.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libutil/shingles.c b/src/libutil/shingles.c index 73fa04ea1..3e0c14b3a 100644 --- a/src/libutil/shingles.c +++ b/src/libutil/shingles.c @@ -89,7 +89,6 @@ rspamd_shingles_get_keys_cached (const guchar key[SHINGLES_KEY_SIZE]) /* Generate keys */ rspamd_cryptobox_hash_init (&bs, NULL, 0); cur_key = key; - out_key = keys[0]; for (i = 0; i < RSPAMD_SHINGLE_SIZE; i ++) { /* @@ -97,13 +96,13 @@ rspamd_shingles_get_keys_cached (const guchar key[SHINGLES_KEY_SIZE]) * initial key as many times as many hashes are required and * xor left and right parts of sha256 to get a single 16 bytes SIP key. */ + out_key = keys[i]; rspamd_cryptobox_hash_update (&bs, cur_key, 16); rspamd_cryptobox_hash_final (&bs, shabuf); memcpy (out_key, shabuf, 16); rspamd_cryptobox_hash_init (&bs, NULL, 0); cur_key = out_key; - out_key = keys[i + 1]; } g_hash_table_insert (ht, key_cpy, keys); -- 2.39.5