/* read key */
/* Check here comments, eol and end of buffer */
if (*p == '#') {
- if (key != NULL && p - c > 0) {
+ if (key != NULL && p - c >= 0) {
value = memory_pool_alloc (pool, p - c + 1);
memcpy (value, c, p - c);
value[p - c] = '\0';
value = g_strstrip (value);
func (data->cur_data, key, value);
+ msg_debug ("insert kv pair: %s -> %s", key, value);
}
data->state = 99;
}
else if (*p == '\r' || *p == '\n' || p - chunk == len - 1) {
- if (key != NULL && p - c > 0) {
+ if (key != NULL && p - c >= 0) {
value = memory_pool_alloc (pool, p - c + 1);
memcpy (value, c, p - c);
value[p - c] = '\0';
value = g_strstrip (value);
func (data->cur_data, key, value);
+ msg_debug ("insert kv pair: %s -> %s", key, value);
+ }
+ else if (key == NULL && p - c > 0) {
+ /* Key only line */
+ key = memory_pool_alloc (pool, p - c + 1);
+ memcpy (key, c, p - c);
+ key[p - c] = '\0';
+ value = memory_pool_alloc (pool, 1);
+ *value = '\0';
+ func (data->cur_data, key, value);
+ msg_debug ("insert kv pair: %s -> %s", key, value);
}
data->state = 100;
key = NULL;
static void
dkim_module_check (struct worker_task *task, rspamd_dkim_context_t *ctx, rspamd_dkim_key_t *key)
{
- gint res, score_allow, score_deny;
+ gint res, score_allow = 1, score_deny = 1;
const gchar *strict_value;
- msg_debug ("check dkim signature for %s domain", ctx->dns_key);
+ msg_debug ("check dkim signature for %s domain from %s", ctx->domain, ctx->dns_key);
res = rspamd_dkim_check (ctx, key, task);
if (dkim_module_ctx->strict_domains != NULL) {
/* Perform strict check */
- if ((strict_value = g_hash_table_lookup (dkim_module_ctx->strict_domains, ctx->dns_key)) != NULL) {
+ if ((strict_value = g_hash_table_lookup (dkim_module_ctx->strict_domains, ctx->domain)) != NULL) {
if (!dkim_module_parse_strict (strict_value, &score_allow, &score_deny)) {
score_allow = dkim_module_ctx->strict_multiplier;
score_deny = dkim_module_ctx->strict_multiplier;
+ msg_debug ("no specific score found for %s domain, using %d for it", ctx->domain, score_deny);
+ }
+ else {
+ msg_debug ("specific score found for %s domain: using %d for deny and %d for allow",
+ ctx->dns_key, score_deny, score_allow);
}
}
}