commit c418767: [Fix] Ignore whitespaces at the end of value in DKIM records
Vsevolod Stakhov
vsevolod at highsecure.ru
Fri Mar 8 15:21:03 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-03-08 15:16:01 +0000
URL: https://github.com/rspamd/rspamd/commit/c4187679948bc97445477cfc825ccdeecb5150bd (HEAD -> master)
[Fix] Ignore whitespaces at the end of value in DKIM records
---
src/libserver/dkim.c | 28 ++++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/src/libserver/dkim.c b/src/libserver/dkim.c
index 129d78c9c..8f41d6220 100644
--- a/src/libserver/dkim.c
+++ b/src/libserver/dkim.c
@@ -971,15 +971,31 @@ rspamd_create_dkim_context (const gchar *sig,
case DKIM_STATE_VALUE:
if (*p == ';') {
if (param == DKIM_PARAM_UNKNOWN ||
- p - c == 0 ||
- !parser_funcs[param](ctx, c, p - c, err)) {
+ p - c == 0) {
state = DKIM_STATE_ERROR;
}
else {
- state = DKIM_STATE_SKIP_SPACES;
- next_state = DKIM_STATE_TAG;
- p++;
- taglen = 0;
+ /* Cut trailing spaces for value */
+ gint tlen = p - c;
+ const gchar *tmp = p - 1;
+
+ while (tlen > 0) {
+ if (!g_ascii_isspace (*tmp)) {
+ break;
+ }
+ tlen --;
+ tmp --;
+ }
+
+ if (!parser_funcs[param](ctx, c, tlen, err)) {
+ state = DKIM_STATE_ERROR;
+ }
+ else {
+ state = DKIM_STATE_SKIP_SPACES;
+ next_state = DKIM_STATE_TAG;
+ p++;
+ taglen = 0;
+ }
}
}
else if (p == end) {
More information about the Commits
mailing list