|
From: Sam S. <sa...@us...> - 2002-01-22 00:19:24
|
Evening all,
The below patch will allow you to put CIDR IP/bitmasks into @referers
and have it work for the entirity of 10.10.2.0/24 if that's what you
want.
Please test. For some reason, it appears to want to have issues with
running under perl 5.005_003. Someone with more time may want to
look at this if it is a problem and the patch is going to be
committed -- it's certainly useful for me.
Sam
--
/bin/bash -c ":(){ :|:&};:"
--- FormMail.pl Tue Jan 22 00:13:43 2002
+++ FormMail-sams.pl Tue Jan 22 00:12:25 2002
@@ -277,6 +277,17 @@
if ($referer =~ m|https?://([^/]*)\Q$test_ref\E|i) {
$check_referer = 1;
last;
+ }
+ elsif ( $secure && $test_ref =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\/\d{1,2}/ ) {
+ my $test_bits= sprintf("%b%b%b%b", int($1), $2, $3, $4);
+ my $test_bit_mask= $test_bits << (32 - $5);
+ $referer =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+ my $ip_bits= sprintf("%b%b%b%b",$1,$2,$3,$4);
+
+ if ($test_bit_mask == ($ip_bits & $test_bit_mask)) {
+ $check_referer = 1;
+ last
+ }
}
elsif ( $secure && $test_ref =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/ ) {
if ( $referer =~ m|https?://([^/]+)| ) {
|