On 5/19/12 12:14 PM, Steven Jan Springl wrote:

> If more than 15 country codes are specified the following error is produced:
> 
> iptables v1.4.13: geoip: too many countries specified
> 
> ERROR: Command "/usr/local/sbin/iptables -A wan2lan -p 6 --dport 80 -m geoip 
> --src-cc GB,GB,GB,GB,GB,GB,GB,GB,GB,GB,GB,GB,GB,GB,GB,GB -m geoip --dst-cc A2 
> -j ACCEPT" Failed

The attached patch corrects this issue and also improves the error
message when an invalid or unknown CC is listed.

Thanks, Steven

-Tom
-- 
Tom Eastep        \ When I die, I want to go like my Grandfather who
Shoreline,         \ died peacefully in his sleep. Not screaming like
Washington, USA     \ all of the passengers in his car
http://shorewall.net \________________________________________________
diff --git a/Shorewall/Perl/Shorewall/Chains.pm 
b/Shorewall/Perl/Shorewall/Chains.pm
index 53bcd5e..58936d7 100644
--- a/Shorewall/Perl/Shorewall/Chains.pm
+++ b/Shorewall/Perl/Shorewall/Chains.pm
@@ -5176,9 +5176,13 @@ sub match_source_net( $;$\$ ) {
        fatal_error "A countrycode list may not be used in this context" if 
$restriction & ( OUTPUT_RESTRICT | POSTROUTE_RESTRICT );
 
        require_capability 'GEOIP_MATCH', 'A country-code', '';
+
+       my @countries = split_list $2, 'cc';
+
+       fatal_error "Too many Country Codes ($2)" if @countries > 15;
  
-       for ( split_list $2, 'cc' ) {
-           fatal_error "Unknown or invalid Country Code" unless $isocodes{$_};
+       for ( @countries ) {
+           fatal_error "Unknown or invalid Country Code ($_)" unless 
$isocodes{$_};
        }
 
        return join( '', '-m geoip ', $1 ? '! ' : '', '--src-cc ', $2 , ' ');
@@ -5243,8 +5247,12 @@ sub imatch_source_net( $;$\$ ) {
 
        require_capability 'GEOIP_MATCH', 'A country-code', '';
 
-       for ( split_list $2, 'cc' ) {
-           fatal_error "Unknown or invalid Country Code" unless $isocodes{$_};
+       my @countries = split_list $2, 'cc';
+
+       fatal_error "Too many Country Codes ($2)" if @countries > 15;
+ 
+       for ( @countries ) {
+           fatal_error "Unknown or invalid Country Code ($_)" unless 
$isocodes{$_};
        }
 
        return ( geoip => , join( '', $1 ? '! ' : '', '--src-cc ', $2 ) );
@@ -5306,8 +5314,12 @@ sub match_dest_net( $;$ ) {
 
        require_capability 'GEOIP_MATCH', 'A country-code', '';
 
-       for ( split_list $2, 'cc' ) {
-           fatal_error "Unknown or invalid Country Code" unless $isocodes{$_};
+       my @countries = split_list $2, 'cc';
+
+       fatal_error "Too many Country Codes ($2)" if @countries > 15;
+ 
+       for ( @countries ) {
+           fatal_error "Unknown or invalid Country Code ($_)" unless 
$isocodes{$_};
        }
 
        return join( '', '-m geoip ', $1 ? '! ' : '', '--dst-cc ', $2, ' ' );
@@ -5367,8 +5379,12 @@ sub imatch_dest_net( $;$ ) {
 
        require_capability 'GEOIP_MATCH', 'A country-code', '';
 
-       for ( split_list $2, 'cc' ) {
-           fatal_error "Unknown or invalid Country Code" unless $isocodes{$_};
+       my @countries = split_list $2, 'cc';
+
+       fatal_error "Too many Country Codes ($2)" if @countries > 15;
+ 
+       for ( @countries ) {
+           fatal_error "Unknown or invalid Country Code ($_)" unless 
$isocodes{$_};
        }
 
        return ( geoip => , join( '', $1 ? '! ' : '', '--dst-cc ', $2 ) );

Attachment: signature.asc
Description: OpenPGP digital signature

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Shorewall-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/shorewall-devel

Reply via email to