Igor Gariev (gariev) wrote in changelog,
Igor Gariev
gariev
changelog

[livejournal] r18324: LJSUP-7811: Whitelist for sysban

Committer: gariev
LJSUP-7811: Whitelist for sysban

U   trunk/cgi-bin/sysban.pl
Modified: trunk/cgi-bin/sysban.pl
===================================================================
--- trunk/cgi-bin/sysban.pl	2011-02-16 10:26:09 UTC (rev 18323)
+++ trunk/cgi-bin/sysban.pl	2011-02-16 10:26:42 UTC (rev 18324)
@@ -447,6 +447,13 @@
                         $matched_wl = $wl;
                         last;
                     }
+                } elsif ($mask =~ /^(\d+\.){1,3}\*$/) {
+                    $mask =~ s/\./\\./g;
+                    $mask =~ s/\*/\.\*/;
+                    if ($ip =~ /^$mask$/) {
+                        $matched_wl = $wl;
+                        last;
+                    }
                 } else {
                     # hm...
                 }
@@ -502,11 +509,18 @@
             my $mask = shift;
             $mask =~ s/\s+//g;
             
-            ## allowed formats: exact IP address, range IP1-IP2, subnet: IP/num
-            if ($mask =~ /^$ip_regexp$/ || $mask =~ /^$ip_regexp-$ip_regexp$/ || $mask =~ m!^$ip_regexp/\d+$!) {
+            ## allowed formats: exact IP address, range IP1-IP2, subnet: IP/num, mask: 123.456.*
+            if (    $mask =~ /^$ip_regexp$/ || 
+                    $mask =~ /^$ip_regexp-$ip_regexp$/ || 
+                    $mask =~ m!^$ip_regexp/\d+$! ||
+                    $mask =~ /^(\d+\.){1,3}\*$/ ) 
+            {
                 return 0;
             } else {
-                return "Format: xxx.xxx.xxx.xxx (exact IP address), or xxx.xxx.xxx.xxx-yyy.yyy.yyy.yyy (IP range) or xxx.xxx.xxx.xxx/yyy (subnet)";
+                return "Format: xxx.xxx.xxx.xxx (exact IP address), " .
+                        "xxx.xxx.xxx.xxx-yyy.yyy.yyy.yyy (IP range),  " .
+                        "xxx.xxx.xxx.xxx/yyy (subnet) or " .
+                        "xxx.xxx.* (mask)";
             }
         }, 
     };

Tags: gariev, livejournal, pl
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments