Bug 162016

Summary: BSDPAN::ExtUtils::Packlist->get_dir_list can go into an infinite loop
Product: Ports & Packages Reporter: Michael G Schwern <schwern>
Component: Individual Port(s)Assignee: freebsd-ports-bugs (Nobody) <ports-bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
get_dir_list.patch none

Description Michael G Schwern 2011-10-26 00:00:19 UTC
See https://rt.cpan.org/Ticket/Display.html?id=70232#txn-991950 for the
upstream report.

BSDPAN::ExtUtils::Packlist can be put into an infinite loop if write()
is given a packlist like "../.packlist".  This happens in the
ExtUtils-MakeMaker tests, specifically t/INSTALL_BASE.t, and was causing
hangs.

I have worked around this in MakeMaker's tests by having them set one
of the magic environment variables it recognizes to disable BSDPAN
registration.  It's a bit distressing that test modules were being
registered.  Perhaps BDSPAN should check that the module in question
is being installed into an official location before registering?  I
don't know how the BSDPAN stuff works.

Fix: 

get_dir_list() is the problem.  It's written in an unsafe fashion.
Instead of hacking off bits of the filepath with a regex and breaking
out of an infinite loop, it is safer and simpler to pull the filepath
apart into a list with File::Spec->splitpath and iterate through it.
How-To-Repeat: cd Some-CPAN-Module (ExtUtils-MakeMaker works)
perl Makefile.PL (to generate a Makefile)

Then run the following Perl program.

    use ExtUtils::Packlist;
    my $packlist = ExtUtils::Packlist->new;
    $packlist->{"Bar.pm"} = 1;
    $packlist->write("../.packlist");

It will enter an infinite loop.
Comment 1 Michael G Schwern 2011-10-26 01:04:39 UTC
Attached is a test and a fix for BSDPAN::ExtUtils::Packlist::get_dir_list().
I patched the version from BSDPAN-5.12.1_20100713.tar.bz2.
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2011-10-26 05:17:39 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-ports-bugs

Reassign to ports. 

To submitter: what port does this PR apply to?
Comment 3 Po-Chuan Hsieh freebsd_committer freebsd_triage 2011-11-16 19:22:32 UTC
State Changed
From-To: open->feedback

Please update your ports tree and upgrade Perl to the latest version. 
This problem should be solved. 

Reference: [1] BSDPAN 20111107 
http://www.freebsd.org/cgi/cvsweb.cgi/ports/lang/perl5.14/Makefile 
http://www.freebsd.org/cgi/cvsweb.cgi/ports/lang/perl5.12/Makefile 
http://www.freebsd.org/cgi/cvsweb.cgi/ports/lang/perl5.10/Makefile 
[2] ports/162151 
http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/162151
Comment 4 Eitan Adler freebsd_committer freebsd_triage 2011-12-25 18:07:28 UTC
State Changed
From-To: feedback->closed

seems like newer perl solves the problem