From: Dave C. <da...@da...> - 2003-03-03 20:17:12
|
Ricky, Thanks for the patch. I've forwarded it to the developers list for discussion. Dave... On Thu, Feb 13, 2003 at 12:28:49PM +0000, Ricky Chan (ric...@br...) wrote: > I work for an ISP and installed your scripts to replace matts scripts. > > The bug is related to DNS entry with more than 1 A record. > > It works perfectly if you use the website name in referers array. (e.g. > qw(www.users.globalnet.co.uk) > > BUT when you use the actual A records > qw(80.189.94.31 80.189.92.31) > > You get occasional failures.. I did some tests and noticed: > > 80.189.92.31,526302544 ne www.users.globalnet.co.uk,526171472 > 80.189.94.31,526171472 ne www.users.globalnet.co.uk,526302544 > > As you see it depends on what inet_aton gets back from a A record for > the website. > > The more A records the more likely hood of not matching and failing. > > The patch I submit, moves the inet_aton for the refHost outside the loop > so does NOT change every iteration. Probs has a small (insignificant) > speed gain as well. > > Apart from the script works a charm and I threw away the old matt > formmail and did need me to write my own. > > > Ricky > --- FormMail.pl Thu Feb 13 12:20:07 2003 > +++ FormMail.pl.orig Thu Feb 13 12:19:34 2003 > @@ -240,17 +240,16 @@ > if ($referer && ($referer =~ m!^https?://([^/]*\@)?([\w\-\.]+)!i)) { > my $refHost; > > $refHost = $2; > - my $ref_host = inet_aton($refHost); > > foreach my $test_ref (@referers) { > if ($refHost =~ m|\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}/ ) { > - if ( $ref_host ) { > + if ( my $ref_host = inet_aton($refHost) ) { > $ref_host = unpack "l", $ref_host; > if ( my $test_ref_ip = inet_aton($test_ref) ) { > $test_ref_ip = unpack "l", $test_ref_ip; > if ( $test_ref_ip == $ref_host ) { > -- .sig missing... |