aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-12-25 12:42:32 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-12-25 12:43:06 +0000
commita7ab8e48f25f9aff1dca95ffa1519e32ec795f75 (patch)
tree8751fc3b4f9676c837b45a8aaa7f04510f18e93f /src/libutil
parent2710693b1af7c8ab6d4147eeb3036751eaa5bbd6 (diff)
downloadrspamd-a7ab8e48f25f9aff1dca95ffa1519e32ec795f75.tar.gz
rspamd-a7ab8e48f25f9aff1dca95ffa1519e32ec795f75.zip
[Fix] Fix indexes in array access, interleave loop
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/shingles.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/libutil/shingles.c b/src/libutil/shingles.c
index bf815c7fc..5676c9c55 100644
--- a/src/libutil/shingles.c
+++ b/src/libutil/shingles.c
@@ -232,17 +232,20 @@ rspamd_shingles_from_image (guchar *dct,
}
memset (res, 0, sizeof (res));
+#define INNER_CYCLE_SHINGLES(s, e) for (j = (s); j < (e); j ++) { \
+ d = dct[beg]; \
+ memcpy (&seed, keys[j], sizeof (seed)); \
+ val = rspamd_cryptobox_fast_hash_specific (ht, \
+ &d, sizeof (d), \
+ seed); \
+ hashes[j][beg] = val; \
+}
+ for (i = 0; i < RSPAMD_DCT_LEN / NBBY; i ++) {
+ INNER_CYCLE_SHINGLES (0, RSPAMD_SHINGLE_SIZE / 4);
+ INNER_CYCLE_SHINGLES (RSPAMD_SHINGLE_SIZE / 4 + 1, RSPAMD_SHINGLE_SIZE / 2);
+ INNER_CYCLE_SHINGLES (RSPAMD_SHINGLE_SIZE / 2 + 1, 3 * RSPAMD_SHINGLE_SIZE / 4);
+ INNER_CYCLE_SHINGLES (3 * RSPAMD_SHINGLE_SIZE / 4 + 1, RSPAMD_SHINGLE_SIZE);
- for (i = 0; i <= RSPAMD_DCT_LEN / NBBY; i ++) {
- for (j = 0; j < RSPAMD_SHINGLE_SIZE; j ++) {
- d = dct[beg];
- /* Insert the last element to the pipe */
- memcpy (&seed, keys[j], sizeof (seed));
- val = rspamd_cryptobox_fast_hash_specific (ht,
- &d, sizeof (d),
- seed);
- hashes[j][beg] = val;
- }
beg++;
}