From: Vsevolod Stakhov Date: Tue, 4 Apr 2017 13:40:13 +0000 (+0100) Subject: [Minor] Fix out-of-bound read X-Git-Tag: 1.5.5~52 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6f1d2064568e8bd3840cd6300608f22c75c4ea80;p=rspamd.git [Minor] Fix out-of-bound read --- 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);