static const gchar *
rspamd_dkim_skip_empty_lines (const gchar *start, const gchar *end,
- guint type, gboolean *need_crlf)
+ guint type, gboolean sign, gboolean *need_crlf)
{
const gchar *p = end - 1, *t;
enum {
state = test_spaces;
}
else {
- if (type != DKIM_CANON_RELAXED) {
+ if (sign || type != DKIM_CANON_RELAXED) {
*need_crlf = TRUE;
}
}
break;
case got_cr:
- if (p > start + 1) {
+ if (p >= start + 1) {
if (*(p - 1) == '\r') {
p --;
state = got_cr;
}
break;
case got_lf:
- if (p > start + 1) {
+ if (p >= start + 1) {
if (*(p - 1) == '\r') {
state = got_crlf;
}
}
break;
case got_crlf:
- if (p > start + 2) {
+ if (p >= start + 2) {
if (*(p - 2) == '\r') {
p -= 2;
state = got_cr;
case test_spaces:
t = p - skip;
- while (t > start + 2 && (*t == ' ' || *t == '\t')) {
+ while (t >= start + 2 && (*t == ' ' || *t == '\t')) {
t --;
}
static gboolean
rspamd_dkim_canonize_body (struct rspamd_dkim_common_ctx *ctx,
const gchar *start,
- const gchar *end)
+ const gchar *end,
+ gboolean sign)
{
const gchar *p;
guint remain = ctx->len ? ctx->len : (guint)(end - start);
}
else {
/* Strip extra ending CRLF */
- p = rspamd_dkim_skip_empty_lines (start, end, ctx->body_canon_type, &need_crlf);
+ p = rspamd_dkim_skip_empty_lines (start, end, ctx->body_canon_type,
+ sign, &need_crlf);
end = p + 1;
if (end == start) {
}
/* Start canonization of body part */
- if (!rspamd_dkim_canonize_body (&ctx->common, body_start, body_end)) {
+ if (!rspamd_dkim_canonize_body (&ctx->common, body_start, body_end, FALSE)) {
return DKIM_RECORD_ERROR;
}
/* Now canonize headers */
}
/* Start canonization of body part */
- if (!rspamd_dkim_canonize_body (&ctx->common, body_start, body_end)) {
+ if (!rspamd_dkim_canonize_body (&ctx->common, body_start, body_end, TRUE)) {
return NULL;
}