aboutsummaryrefslogtreecommitdiff
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
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
-rw-r--r--ChangeLog36
-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
-rw-r--r--src/gram.y50
-rw-r--r--src/lex.l41
-rw-r--r--src/mailfromd.h10
-rw-r--r--src/status.mfi20
-rw-r--r--src/symtab.c38
-rw-r--r--tests/etc/catch.rc4
-rw-r--r--tests/etc/catch01.rc6
12 files changed, 187 insertions, 60 deletions
diff --git a/ChangeLog b/ChangeLog
index f1ecc135..9abbf87e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,39 @@
12008-03-09 Sergey Poznyakoff <gray@gnu.org.ua>
2
3 Name clashes between constants and variables went unnoticed by the
4 compiler. Bug reported by Thomas Lynch.
5 Fix this and rename exception codes to minimize chances of such
6 clashes.
7
8 * src/symtab.c (lookup_or_install): Allow to search using state
9 masks.
10 (variable_or_constant_lookup): New function.
11 (constant_lookup): Return const struct constant *.
12 (constant_lookup_value): New function.
13 * src/lex.l (get_const): Remove.
14 (variable_or_const): New function.
15 * src/gram.y: Display warnings on a clash of constant and variable
16 names.
17 (VARIABLE): Change union type to var. Modify `variable' production
18 accordingly.
19 * src/mailfromd.h (_SYM_COUNT,SYM_MASK,SYM_BITS): New defines.
20 (constant_lookup): Return const struct constant *.
21 (constant_lookup_value): New function.
22 (variable_or_constant_lookup): New function.
23 * src/status.mfi: Prefix exception codes with `e_' to avoid name
24 clashes.
25 Provide backward-compatible constants.
26 * mflib/match_dnsbl.mf (match_dnsbl): Rename range to iprange to
27 avoid name clashes with the exception code.
28 Remove buggy conditions. Provide a correctly working replacement
29 for them if the m3 symbol `COMPAT_4_3' is defined.
30 * mflib/match_rhsbl.mf (match_rhsbl): Rename range to iprange to
31 avoid name clashes with the exception code.
32 Remove buggy conditions. Provide a correctly working replacement
33 for them if the m3 symbol `COMPAT_4_3' is defined.
34 * mflib/match_cidr.mf, mflib/safedb.mf4, tests/etc/catch.rc,
35 tests/etc/catch01.rc: Use new exception codes.
36
12008-03-01 Sergey Poznyakoff <gray@gnu.org.ua> 372008-03-01 Sergey Poznyakoff <gray@gnu.org.ua>
2 38
3 * src/prog.c, src/prog.h (advance_pc): Fix type of the 2nd 39 * src/prog.c, src/prog.h (advance_pc): Fix type of the 2nd
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 @@
1/* Implementation of match_cidr call 1/* Implementation of match_cidr call
2 Copyright (C) 2007 Sergey Poznyakoff 2 Copyright (C) 2007, 2008 Sergey Poznyakoff
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@ do
25 if %cidr matches '^(([0-9]{1,3}\.){3}[0-9]{1,3})/([0-9][0-9]?)' 25 if %cidr matches '^(([0-9]{1,3}\.){3}[0-9]{1,3})/([0-9][0-9]?)'
26 return inet_aton(%ipstr) & len_to_netmask(\3) = inet_aton(\1) 26 return inet_aton(%ipstr) & len_to_netmask(\3) = inet_aton(\1)
27 else 27 else
28 throw invcidr "invalid CIDR (%cidr)" 28 throw e_invcidr "invalid CIDR (%cidr)"
29 fi 29 fi
30 return 0 30 return 0
31done 31done
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 @@
1/* DNSBL checker. 1/* DNSBL checker.
2 Copyright (C) 2006, 2007 Jan Rafaj 2 Copyright (C) 2006, 2007 Jan Rafaj
3 Copyright (C) 2008 Sergey Poznyakoff
3 4
4 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -19,27 +20,26 @@
19 20
20#pragma regex push +extended 21#pragma regex push +extended
21 22
22func match_dnsbl(string address, string zone, string range) 23func match_dnsbl(string address, string zone, string iprange)
23 returns number 24 returns number
24do 25do
25 string rbl_ip 26 if %iprange = 'ANY'
26 if %range = 'ANY' 27 set iprange '127.0.0.0/8'
27 set rbl_ip '127.0.0.0/8' 28 m4_ifdef(`COMPAT_4_3',`
28 else 29 else
29 set rbl_ip %range 30 if not %iprange matches `'''`^([0-9]{1,3}\.){3}[0-9]{1,3}/[0-9]{1,2}$`'''`
30 if not %range matches '^([0-9]{1,3}\.){3}[0-9]{1,3}$'
31 return 0 31 return 0
32 fi 32 fi
33 fi 33 fi
34 34
35 if not (%address matches '^([0-9]{1,3}\.){3}[0-9]{1,3}$' 35 if not (%address matches `'''`^([0-9]{1,3}\.){3}[0-9]{1,3}$`'''`
36 and %address != %range) 36 and %address != %iprange)
37 return 0 37 return 0')
38 fi 38 fi
39 39
40 if %address matches 40 if %address matches
41 '^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$' 41 '^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$'
42 if match_cidr (resolve ("\4.\3.\2.\1", %zone), %rbl_ip) 42 if match_cidr (resolve ("\4.\3.\2.\1", %zone), %iprange)
43 return 1 43 return 1
44 else 44 else
45 return 0 45 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 @@
1/* RHSBL checker. 1/* RHSBL checker.
2 Copyright (C) 2006, 2007 Jan Rafaj 2 Copyright (C) 2006, 2007 Jan Rafaj
3 Copyright (C) 2008 Sergey Poznyakoff
3 4
4 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -18,14 +19,17 @@
18#require match_cidr 19#require match_cidr
19 20
20#pragma regex push +extended 21#pragma regex push +extended
21func match_rhsbl(string email, string zone, string range) 22func match_rhsbl(string email, string zone, string iprange)
22 returns number 23 returns number
23do 24do
24 if not (%email matches '@.+$' 25 if %iprange = 'ANY'
25 and %range matches '^([0-9]{1,3}\.){3}[0-9]{1,3}$') 26 set iprange '127.0.0.0/8'
27 fi
28 if not (%email matches '@.+$'m4_ifdef(`COMPAT_4_3',`
29 and %iprange matches `'''`^([0-9]{1,3}\.){3}[0-9]{1,3}/[0-9]{1,2}$'`''))
26 return 0 30 return 0
27 fi 31 fi
28 32
29 return match_cidr (resolve ((domainpart %email), %zone), %range) 33 return match_cidr (resolve ((domainpart %email), %zone), %iprange)
30done 34done
31#pragma regex pop 35#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 @@
1/* Safe DB I/O 1/* Safe DB I/O
2 Copyright (C) 2007 Sergey Poznyakoff 2 Copyright (C) 2007, 2008 Sergey Poznyakoff
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
@@ -19,7 +19,7 @@
19func safedbget(string name, string key ; string defval, number null) 19func safedbget(string name, string key ; string defval, number null)
20 returns string 20 returns string
21do 21do
22 catch dbfailure 22 catch e_dbfailure
23 do 23 do
24 return "" 24 return ""
25 done 25 done
@@ -34,7 +34,7 @@ done
34 34
35func safedbput(string name, string key, string value ; number null) 35func safedbput(string name, string key, string value ; number null)
36do 36do
37 catch dbfailure 37 catch e_dbfailure
38 do 38 do
39 return 39 return
40 done 40 done
diff --git a/src/gram.y b/src/gram.y
index 7732007f..bb68ded5 100644
--- a/src/gram.y
+++ b/src/gram.y
@@ -1,6 +1,6 @@
1%{ 1%{
2/* This file is part of mailfromd. 2/* This file is part of mailfromd.
3 Copyright (C) 2005, 2006, 2007 Sergey Poznyakoff 3 Copyright (C) 2005, 2006, 2007, 2008 Sergey Poznyakoff
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -281,7 +281,7 @@ static void register_macro(enum smtp_state tag, const char *macro);
281%} 281%}
282 282
283%error-verbose 283%error-verbose
284%expect 26 284%expect 27
285 285
286%union { 286%union {
287 struct literal *literal;