[prev in list] [next in list] [prev in thread] [next in thread] 

List:       dovecot
Subject:    Re: Antispam plugin: insufficent error messages
From:       Timo Sirainen <tss () iki ! fi>
Date:       2016-12-18 10:00:46
Message-ID: EA11B843-89AB-4BE6-BB6A-1B981850F196 () iki ! fi
[Download RAW message or body]

On 18 Dec 2016, at 0.57, Tom Talpey <tom@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;
> }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic