From: Vsevolod Stakhov Date: Fri, 3 Sep 2021 09:09:40 +0000 (+0100) Subject: [Fix] Fix the case when l tag is too small X-Git-Tag: 3.1~196 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ab400b4b6564fdd64cb6ed70671fe979743c305;p=thirdparty%2Frspamd.git [Fix] Fix the case when l tag is too small --- diff --git a/src/libserver/dkim.c b/src/libserver/dkim.c index 9dde51529d..46b4b89362 100644 --- a/src/libserver/dkim.c +++ b/src/libserver/dkim.c @@ -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) {