[Exim] Possible bug in regular expression matching with ${ev…

Góra strony
Delete this message
Reply to this message
Autor: Ralf Ertzinger
Data:  
Dla: exim-users
Temat: [Exim] Possible bug in regular expression matching with ${eval:..}
Hi.

I think I have found a bug in exim's regular expression handling.

The background:
I am posting to usenet with addresses of the form
"usenet-yyyymmdd@???", where yyyymmdd denotes the date
of the posting.

Since I am getting just SPAM via these addresses, I recently decided
to reject all addresses fo this form where yyyymmdd is older that
roughly one year (stating an alternate address in the reject message
in case a real human being sent the mail).

To do this, I added the following to acl_check_rcpt:

 deny    domains       = +local_domains : +virtual_domains
          local_parts   = ^usenet-(\\d{8})\$
          set acl_m0    = ${if match{$tod_log}{^\N(\d\d\d\d)-(\d\d)-(\d\d)\N}\
                              {${eval:($1*12)+$2}}{0}}
          set acl_m1    = ${if match{$local_part}{^usenet-\N(\d{4})(\d{2})\N}\
                            {${eval:($1*12)+$2}}{0}}
          set acl_m2    = ${eval:$acl_m0-$acl_m1}
          set acl_m3    = ${if <{$acl_m2}{13}{no}{yes}}
          message       = This address has expired. Use usenet@??? instead.
          condition     = ${if eq{$acl_m3}{yes}{yes}{no}}
          delay         = 30s


As you can see, I am first calculating the current month's number
(year*12 + month) in acl_m0, then the number of the month given in the
recipients address in acl_m1. Further along the difference is calculated,
and if too large, the mail is rejected.

This works fine. Most of the time.

The strange bug is that it does work as long as the month is not 08 or 09.
Example:

RCPT TO:<usenet-20020101@???>
(30 seconds delay here)
550 This address has expired. Use usenet@??? instead.
RCPT TO:<usenet-20040101@???>
250 OK
RCPT TO:<usenet-20020904@???>
451 Temporary local problem - please try later


When issuing the last RCPT TO command, the following is written to the
log files (linebreaks added):

2004-03-04 16:04:50 H=[xxx.xxx.xxx.xxx] F=<ralf@???> temporarily
rejected RCPT <usenet-20020904@???>: failed to expand ACL string
"${if match{$local_part}{^usenet-\N(\d{4})(\d{2})\N}{${eval:($1*12)+$2}}{0}}":
error in expression evaluation: expecting + or - (after processing "(2002*12)+0")

So it seems exim fails to expand $2 for some strange reason. This just happens
if $2 ought to be 08 or 09 (19, for example, works fine).

Any thoughs on that?

Thanks.