From: Vsevolod Stakhov Date: Thu, 7 May 2015 11:24:48 +0000 (+0100) Subject: Some fixes for vectorized encryption. X-Git-Tag: 0.9.0~79 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=24f4bdee9db31af467f8d23992555d1a39435fb5;p=rspamd.git Some fixes for vectorized encryption. --- diff --git a/src/libcryptobox/cryptobox.c b/src/libcryptobox/cryptobox.c index 9ab8f93c2..4ca3d3238 100644 --- a/src/libcryptobox/cryptobox.c +++ b/src/libcryptobox/cryptobox.c @@ -238,6 +238,10 @@ void rspamd_cryptobox_encryptv_nm_inplace (struct rspamd_cryptobox_segment *segm seg_offset = 0; for (;;) { + if (cur - segments == cnt) { + break; + } + if (cur->len <= remain) { memcpy (out, cur->data, cur->len); remain -= cur->len; @@ -275,15 +279,18 @@ void rspamd_cryptobox_encryptv_nm_inplace (struct rspamd_cryptobox_segment *segm memcpy (in, outbuf, sizeof (outbuf)); in += sizeof (outbuf); inremain -= sizeof (outbuf); + remain = sizeof (outbuf); } else { memcpy (outbuf, in, inremain); remain = sizeof (outbuf) - inremain; - cur ++; - seg_offset = inremain; + inremain = 0; } } + + cur ++; + seg_offset = inremain; } }