]> source.dussan.org Git - rspamd.git/commitdiff
Some fixes for vectorized encryption.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 7 May 2015 11:24:48 +0000 (12:24 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 7 May 2015 11:24:48 +0000 (12:24 +0100)
src/libcryptobox/cryptobox.c

index 9ab8f93c245bb282259013f668db8cc792746e2b..4ca3d32387da78fcbe1d035c45f894f9565ac27c 100644 (file)
@@ -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;
                }
        }