Antispam plugin: insufficent error messages

Timo Sirainen tss at iki.fi
Sun Dec 18 10:00:46 UTC 2016


On 18 Dec 2016, at 0.57, Tom Talpey <tom at talpey.com> wrote:
> 
> 
> I too encountered this same issue after upgrading to 2.2.27. I traced it
> to an apparent change in Dovecot's mail_get_headers() function, which
> now returns a non-zero value even when the header is found. This wasn't
> the behavior in 2.2.24, though I'm not sure if it was in .25 or .26.
> I haven't tracked down the details further.
> 
> Anyway, the antispam plugin uses this API to find the X-DSPAM-Signature
> header, and the change causes the plugin to abort. This happens in the
> plugin's antispam-plugin.h wrapper, which I modified as follows.
> 
> I'm confused why the dovecot API behavior changed, but I hope this
> helps!

It was mostly an accident. There was a mismatch between mail_get_headers() and mail_get_headers_utf8() return values, which was fixed the wrong way. Also I think there might have been some code that assumed that mail_get_headers() would return > 0 on success. Anyway, too late to change back now...

> ! 	const char *const *ret = NULL;
> ! 	mail_get_headers(mail, hdr, &ret);
>  	return ret;

That works, but maybe a nicer way that works for both old and new API and checks also the return value:

if (mail_get_headers(mail, hdr, &ret) < 0)
  return NULL;

>  }
> 
> --- 268,276 ----
>  static inline const char *const *
>  get_mail_headers(struct mail *mail, const char *hdr)
>  {
> ! 	const char *const *ret;
> ! 	if (mail_get_headers(mail, hdr, &ret))
> ! 		return NULL;
>  	return ret;
>  }



More information about the dovecot mailing list