aboutsummaryrefslogtreecommitdiff
path: root/mflib
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2008-03-09 10:04:03 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2008-03-09 10:04:03 +0000
commit14cc2f2806c7b66992ca4a41d6f8da6020931194 (patch)
treef757e0b384ec5980da28790150f888e67f35fedb /mflib
parent17e8d87f2b9ece032bc4408b89918f0b366abc85 (diff)
downloadmailfromd-14cc2f2806c7b66992ca4a41d6f8da6020931194.tar.gz
mailfromd-14cc2f2806c7b66992ca4a41d6f8da6020931194.tar.bz2
Name clashes between constants and variables went unnoticed by the
compiler. Bug reported by Thomas Lynch. Fix this and rename exception codes to minimize chances of such clashes. * src/symtab.c (lookup_or_install): Allow to search using state masks. (variable_or_constant_lookup): New function. (constant_lookup): Return const struct constant *. (constant_lookup_value): New function. * src/lex.l (get_const): Remove. (variable_or_const): New function. * src/gram.y: Display warnings on a clash of constant and variable names. (VARIABLE): Change union type to var. Modify `variable' production accordingly. * src/mailfromd.h (_SYM_COUNT,SYM_MASK,SYM_BITS): New defines. (constant_lookup): Return const struct constant *. (constant_lookup_value): New function. (variable_or_constant_lookup): New function. * src/status.mfi: Prefix exception codes with `e_' to avoid name clashes. Provide backward-compatible constants. * mflib/match_dnsbl.mf (match_dnsbl): Rename range to iprange to avoid name clashes with the exception code. Remove buggy conditions. Provide a correctly working replacement for them if the m3 symbol `COMPAT_4_3' is defined. * mflib/match_rhsbl.mf (match_rhsbl): Rename range to iprange to avoid name clashes with the exception code. Remove buggy conditions. Provide a correctly working replacement for them if the m3 symbol `COMPAT_4_3' is defined. * mflib/match_cidr.mf, mflib/safedb.mf4, tests/etc/catch.rc, tests/etc/catch01.rc: Use new exception codes. git-svn-id: file:///svnroot/mailfromd/branches/release_4_3_patches@1627 7a8a7f39-df28-0410-adc6-e0d955640f24
Diffstat (limited to 'mflib')
-rw-r--r--mflib/match_cidr.mf4
-rw-r--r--mflib/match_dnsbl.mf20
-rw-r--r--mflib/match_rhsbl.mf12
-rw-r--r--mflib/safedb.mf46
4 files changed, 23 insertions, 19 deletions
diff --git a/mflib/match_cidr.mf b/mflib/match_cidr.mf
index bb3470ad..24220ab4 100644
--- a/mflib/match_cidr.mf
+++ b/mflib/match_cidr.mf
@@ -1,5 +1,5 @@
/* Implementation of match_cidr call
- Copyright (C) 2007 Sergey Poznyakoff
+ Copyright (C) 2007, 2008 Sergey Poznyakoff
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@ do
if %cidr matches '^(([0-9]{1,3}\.){3}[0-9]{1,3})/([0-9][0-9]?)'
return inet_aton(%ipstr) & len_to_netmask(\3) = inet_aton(\1)
else
- throw invcidr "invalid CIDR (%cidr)"
+ throw e_invcidr "invalid CIDR (%cidr)"
fi
return 0
done
diff --git a/mflib/match_dnsbl.mf b/mflib/match_dnsbl.mf
index 0621a98c..53603be5 100644
--- a/mflib/match_dnsbl.mf
+++ b/mflib/match_dnsbl.mf
@@ -1,5 +1,6 @@
/* DNSBL checker.
Copyright (C) 2006, 2007 Jan Rafaj
+ Copyright (C) 2008 Sergey Poznyakoff
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,27 +20,26 @@
#pragma regex push +extended
-func match_dnsbl(string address, string zone, string range)
+func match_dnsbl(string address, string zone, string iprange)
returns number
do
- string rbl_ip
- if %range = 'ANY'
- set rbl_ip '127.0.0.0/8'
+ if %iprange = 'ANY'
+ set iprange '127.0.0.0/8'
+ m4_ifdef(`COMPAT_4_3',`
else
- set rbl_ip %range
- if not %range matches '^([0-9]{1,3}\.){3}[0-9]{1,3}$'
+ if not %iprange matches `'''`^([0-9]{1,3}\.){3}[0-9]{1,3}/[0-9]{1,2}$`'''`
return 0
fi
fi
- if not (%address matches '^([0-9]{1,3}\.){3}[0-9]{1,3}$'
- and %address != %range)
- return 0
+ if not (%address matches `'''`^([0-9]{1,3}\.){3}[0-9]{1,3}$`'''`
+ and %address != %iprange)
+ return 0')
fi
if %address matches
'^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$'
- if match_cidr (resolve ("\4.\3.\2.\1", %zone), %rbl_ip)
+ if match_cidr (resolve ("\4.\3.\2.\1", %zone), %iprange)
return 1
else
return 0
diff --git a/mflib/match_rhsbl.mf b/mflib/match_rhsbl.mf
index 9b2a492a..d08f103b 100644
--- a/mflib/match_rhsbl.mf
+++ b/mflib/match_rhsbl.mf
@@ -1,5 +1,6 @@
/* RHSBL checker.
Copyright (C) 2006, 2007 Jan Rafaj
+ Copyright (C) 2008 Sergey Poznyakoff
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,14 +19,17 @@
#require match_cidr
#pragma regex push +extended
-func match_rhsbl(string email, string zone, string range)
+func match_rhsbl(string email, string zone, string iprange)
returns number
do
- if not (%email matches '@.+$'
- and %range matches '^([0-9]{1,3}\.){3}[0-9]{1,3}$')
+ if %iprange = 'ANY'
+ set iprange '127.0.0.0/8'
+ fi
+ if not (%email matches '@.+$'m4_ifdef(`COMPAT_4_3',`
+ and %iprange matches `'''`^([0-9]{1,3}\.){3}[0-9]{1,3}/[0-9]{1,2}$'`''))
return 0
fi
- return match_cidr (resolve ((domainpart %email), %zone), %range)
+ return match_cidr (resolve ((domainpart %email), %zone), %iprange)
done
#pragma regex pop
diff --git a/mflib/safedb.mf4 b/mflib/safedb.mf4
index f1d98b8a..822d3c7a 100644
--- a/mflib/safedb.mf4
+++ b/mflib/safedb.mf4
@@ -1,5 +1,5 @@
/* Safe DB I/O
- Copyright (C) 2007 Sergey Poznyakoff
+ Copyright (C) 2007, 2008 Sergey Poznyakoff
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,7 +19,7 @@
func safedbget(string name, string key ; string defval, number null)
returns string
do
- catch dbfailure
+ catch e_dbfailure
do
return ""
done
@@ -34,7 +34,7 @@ done
func safedbput(string name, string key, string value ; number null)
do
- catch dbfailure
+ catch e_dbfailure
do
return
done

Return to:

Send suggestions and report system problems to the System administrator.