commit 29929c3: [Minor] Fix some corner case with l tag in DKIM
Vsevolod Stakhov
vsevolod at highsecure.ru
Tue Mar 3 22:15:29 UTC 2020
Author: Vsevolod Stakhov
Date: 2020-03-03 13:19:22 +0000
URL: https://github.com/rspamd/rspamd/commit/29929c32eeb0e17b5813459c76f6521105c1929e
[Minor] Fix some corner case with l tag in DKIM
---
src/libserver/dkim.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/src/libserver/dkim.c b/src/libserver/dkim.c
index 1bd7ec3d6..8b1ac24ab 100644
--- a/src/libserver/dkim.c
+++ b/src/libserver/dkim.c
@@ -1914,6 +1914,7 @@ rspamd_dkim_canonize_body (struct rspamd_dkim_common_ctx *ctx,
{
const gchar *p;
guint remain = ctx->len ? ctx->len : (guint)(end - start);
+ guint total_len = end - start;
gboolean need_crlf = FALSE;
if (start == NULL) {
@@ -1948,10 +1949,32 @@ rspamd_dkim_canonize_body (struct rspamd_dkim_common_ctx *ctx,
while (rspamd_dkim_simple_body_step (ctx, ctx->body_hash,
&start, end - start, &remain));
+ /*
+ * If we have l= tag then we cannot add crlf...
+ */
if (need_crlf) {
+ /* l is evil... */
+ if (ctx->len == 0) {
+ remain = 2;
+ }
+ else {
+ if (ctx->len <= total_len) {
+ /* We don't have enough l to add \r\n */
+ remain = 0;
+ }
+ else {
+ if (ctx->len - total_len >= 2) {
+ remain = 2;
+ }
+ else {
+ remain = ctx->len - total_len;
+ }
+ }
+ }
+
start = "\r\n";
end = start + 2;
- remain = 2;
+
rspamd_dkim_simple_body_step (ctx, ctx->body_hash,
&start, end - start, &remain);
}
More information about the Commits
mailing list