commit 0ab400b: [Fix] Fix the case when l tag is too small

Vsevolod Stakhov vsevolod at highsecure.ru
Fri Sep 3 09:14:04 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-09-03 10:09:40 +0100
URL: https://github.com/rspamd/rspamd/commit/0ab400b4b6564fdd64cb6ed70671fe979743c305 (HEAD -> master)

[Fix] Fix the case when l tag is too small

---
 src/libserver/dkim.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/libserver/dkim.c b/src/libserver/dkim.c
index 9dde51529..46b4b8936 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) {


More information about the Commits mailing list