]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix the case when l tag is too small
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 3 Sep 2021 09:09:40 +0000 (10:09 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 3 Sep 2021 09:09:40 +0000 (10:09 +0100)
src/libserver/dkim.c

index 9dde51529dc0eb08bd6a8c0ce361a4c90de539a2..46b4b89362056cf6a567d1d07f05d170f7bd7e51 100644 (file)
@@ -1711,7 +1711,7 @@ rspamd_dkim_relaxed_body_step (struct rspamd_dkim_common_ctx *ctx, EVP_MD_CTX *c
        got_sp = FALSE;
        octets_remain = *remain;
 
-       while (len > 0 && inlen > 0 && (octets_remain != 0)) {
+       while (len > 0 && inlen > 0 && (octets_remain > 0)) {
 
                if (*h == '\r' || *h == '\n') {
                        if (got_sp) {
@@ -1766,6 +1766,14 @@ rspamd_dkim_relaxed_body_step (struct rspamd_dkim_common_ctx *ctx, EVP_MD_CTX *c
                octets_remain --;
        }
 
+       if (octets_remain < 0) {
+               /* Absurdic l tag value, but we still need to rewind the t pointer back */
+               while (t > buf && octets_remain < 0) {
+                       t --;
+                       octets_remain ++;
+               }
+       }
+
        *start = h;
 
        if (t - buf > 0) {