Subject: | Doesn't check for $HOME w/ fix |
I have been tracking down a problem in a CGI script which causes a lot
of entries such as this in error.log:
[Sat Jan 22 06:07:21 2011] [error] [client 82.80.249.230] [Sat Jan 22
06:07:21 2011] search.cgi: Use of uninitialized value $_[0] in join or
string at /home/nigelhorne/perlmods/lib/perl/5.10/File/Spec/Unix.pm line 95.
After much searching I've tracked the problem to this line in
Config::Auto::find_file:
return $x if -e ($x = catfile($ENV{HOME},$filename));
The problem is the assumption that there is a $HOME environment
variable, which isn't true in CGI, coupled with File::Spec::Unix's lack
of sanity checking of its arguments.
The simple fix is:
return $x if ($ENV{HOME} && -e ($x = catfile($ENV{HOME},$filename)));