Re: Unsuccessful stat on filename containing newline in RegistryCooker.pm

Torsten Förtsch <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <[email protected]>
On 02/14/2013 02:39 AM, Michael A. Capone wrote:
> [Wed Feb 13 16:27:33 2013] [error] [client 192.168.254.21] Unsuccessful
> stat on filename containing newline at
> /usr/local/lib64/perl5/ModPerl/RegistryCooker.pm line 787.\n
> 
> ... which in turn results in a 500 Server Error.

The culprit here is only partly modperl. Line 787 reads

  stat ...

This is the plain perl stat function. Nothing to do with modperl.

The reason why it throws an exception is line 26 which reads:

  use warnings FATAL => 'all';

See:

$ perl -le 'stat "fritz\r\n"; print "no exception"'
no exception

$ perl -Mwarnings -le 'stat "fritz\r\n"; print "no exception"'
Unsuccessful stat on filename containing newline at -e line 1.
no exception

$ perl -Mwarnings=FATAL,all -le 'stat "fritz\r\n"; print "no exception"'
Unsuccessful stat on filename containing newline at -e line 1.



Only the last one dies. Perl itself explains:

$ perl -Mdiagnostics -Mwarnings=FATAL,all \
       -le 'stat "fritz\r\n"; print "no exception"'
Unsuccessful stat on filename containing newline at -e line 1 (#1)
    (W newline) A file operation was attempted on a filename, and that
    operation failed, PROBABLY because the filename contained a newline,
    PROBABLY because you forgot to chomp() it off.  See perlfunc/chomp.

Uncaught exception from user code:
        Unsuccessful stat on filename containing newline at -e line 1.
 at -e line 1



It also shows a way how to prevent it:

$ perl -Mwarnings=FATAL,all \
       -le '{no warnings "newline"; stat "fritz\r\n";}
            print "no exception"'
no exception



I agree with you that the behavior is unexpected. Also, the XXX comment
in line 783 points out that my_finfo() is a temporary solution. So,
perhaps it would be best to use APR::Finfo here. If family allows it
I'll fix it over the weekend.

Torsten
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.