Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pod::Html infinite recursion #6963

Closed
p5pRT opened this issue Dec 6, 2003 · 6 comments
Closed

Pod::Html infinite recursion #6963

p5pRT opened this issue Dec 6, 2003 · 6 comments

Comments

@p5pRT
Copy link

p5pRT commented Dec 6, 2003

Migrated from rt.perl.org#24610 (status was 'resolved')

Searchable as RT24610$

@p5pRT
Copy link
Author

p5pRT commented Dec 6, 2003

From ajohnson@nvidia.com

Created by ajohnson@nvidia.com

This is a bug report for perl from ajohnson@​nvidia.com,
generated with the help of perlbug 1.34 running under perl v5.8.2.

-----------------------------------------------------------------
Pod​::Html will recurse forever if there is a symbolic link to a
superdirectory within a directory specified in -podpath.

(In our environment, there is a symbolic link to the "top of source
configuration" in every directory, and this has been found to be extremely
useful. However, it exposes this bug rather egregiously.)

One way to deal with this is to prune the recursion on any directory that
is both hidden and a symbolic link. The included patch does just that. I
admit that this reeks of hackery, but I thought that pruning simply on any
symbolic link or simply on any hidden directory was likely to break
something that might currently rely on it working as it does.

Another reasonable way to deal with this is to add an option not to follow
hidden directories. This solution has the advantage that it couldn't
possibly break anything.

One could make the recursion finite by pruning visited directories, but
this is *not* the desired behavior. (In our case, that would cause the
entire source configuration to be searched.)

I'm perfectly happy to implement the fix if somebody can tell me what the
right answer is.

----- perl-5.8.2-podscan.patch -----

Inline Patch
diff -Naur perl-5.8.2/lib/Pod/Html.pm perl-5.8.2-podscan/lib/Pod/Html.pm
--- perl-5.8.2/lib/Pod/Html.pm  Tue Sep 30 10:11:02 2003
+++ perl-5.8.2-podscan/lib/Pod/Html.pm  Tue Nov 11 17:31:19 2003
@@ -921,7 +921,9 @@
     opendir(DIR, $dir) ||
        die "$0: error opening directory $dir: $!\n";
     while (defined($_ = readdir(DIR))) {
-       if (-d "$dir/$_" && $_ ne "." && $_ ne "..") {      # directory
+       if (-d "$dir/$_" && $_ ne "." && $_ ne ".." &&
+         (!-l "$dir/$_" || !/^\./)
+       ) {         # directory
            $Pages{$_}  = "" unless defined $Pages{$_};
            $Pages{$_} .= "$dir/$_:";
            push(@subdirs, $_);
Perl Info

Flags:
    category=library
    severity=medium

Site configuration information for perl v5.8.2:

Configured by ajohnson at Tue Nov 11 17:05:24 PST 2003.

Summary of my perl5 (revision 5.0 version 8 subversion 2) configuration:
  Platform:
    osname=linux, osvers=2.4.21+nfs_fixes, archname=i686-linux
    uname='linux l-sim-241-78 2.4.21+nfs_fixes #8 smp tue jul 15 13:37:04 pdt 2003 i686 unknown '
    config_args='-Dprefix=/home/ajohnson/tools -de'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    optimize='-O2',
    cppflags='-fno-strict-aliasing -I/usr/local/include -I/usr/include/gdbm'
    ccversion='', gccversion='2.96 20000731 (Red Hat Linux 7.1 2.96-98)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.2.4.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.2.4'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.8.2:
    /home/ajohnson/tools/lib/perl5/5.8.2/i686-linux
    /home/ajohnson/tools/lib/perl5/5.8.2
    /home/ajohnson/tools/lib/perl5/site_perl/5.8.2/i686-linux
    /home/ajohnson/tools/lib/perl5/site_perl/5.8.2
    /home/ajohnson/tools/lib/perl5/site_perl
    .


Environment for perl v5.8.2:
    HOME=/home/ajohnson
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH=.:/home/nc4.42/tools/lib:/usr/local/lsf/lib:.:/home/nc4.42/tools/lib:/usr/local/lsf/lib:/usr/local/lsf/lib:.:/home/nc4.42/tools/lib:/usr/local/lsf/lib:.:/home/nc4.42/tools/lib:/usr/local/lsf/lib:.:/usr/lib
    LOGDIR (unset)
    PATH=/home/nc4.42/tools/bin:/home/nc4.42/tools/dfII/bin:.:/home/ajohnson/bin:/home/gnu/bin:/usr/bin:/usr/openwin/bin:/sbin:/usr/sbin:/usr/ucb:/usr/ccs/bin:/usr/dt/bin:/bin:/usr/lib:/etc:/home/nv/bin:/home/gnu/X11R6.3/lib:/usr/bin/X11:/usr/local/lsf/bin:/usr/local/wp/wpbin:/usr/local/lsf/bin:/home/tools/td/td5303/linux/bin:/home/synopsys/2000.11/linux/syn/bin:/home/synopsys/pt_2000.11/linux/syn/bin:/home/synopsys/2000.11/linux/mc/bin:/home/synopsys/fm_2001.08/linux/fm/bin:/home/frame/bin:/home/tools/verilint/2001.4.10-linux2.2:/home/tools/vcs/vcs_latest/virsimdir//bin:/home/xl_98/tools/verilog/bin:/home/xl_98/tools/bin:/home/tools/vcs/vcs_latest/bin:/home/powerview:/home/powerview/standard:/home/tools/debussy/latest/bin:/home/tools/debussy/verdi_latest/bin:/home/imodl/p6/bin/i686-linux2.4.21+NFS_FIXES
    PERL_BADLANG (unset)
    SHELL=/home/gnu/bin/tcsh

@p5pRT
Copy link
Author

p5pRT commented Dec 12, 2003

From @rgs

ajohnson@​nvidia.com (via RT) wrote​:

Pod​::Html will recurse forever if there is a symbolic link to a
superdirectory within a directory specified in -podpath.

(In our environment, there is a symbolic link to the "top of source
configuration" in every directory, and this has been found to be extremely
useful. However, it exposes this bug rather egregiously.)

One way to deal with this is to prune the recursion on any directory that
is both hidden and a symbolic link. The included patch does just that. I
admit that this reeks of hackery, but I thought that pruning simply on any
symbolic link or simply on any hidden directory was likely to break
something that might currently rely on it working as it does.

Thinking about this, pruning hidden directories -- turned on by default,
but disableable -- might be a good idea ; hidden directories are often
used to store private data or configuration data, or even cached data
(for example Subversion stores pristine copies of files in .svn subdirs).
I think that would be a good default behaviour. Russ, any opinion ?

Another reasonable way to deal with this is to add an option not to follow
hidden directories. This solution has the advantage that it couldn't
possibly break anything.

@p5pRT
Copy link
Author

p5pRT commented Dec 12, 2003

From rra@stanford.edu

Rafael Garcia-Suarez <rgarciasuarez@​free.fr> writes​:

ajohnson@​nvidia.com (via RT) wrote​:

Pod​::Html will recurse forever if there is a symbolic link to a
superdirectory within a directory specified in -podpath.

(In our environment, there is a symbolic link to the "top of source
configuration" in every directory, and this has been found to be
extremely useful. However, it exposes this bug rather egregiously.)

One way to deal with this is to prune the recursion on any directory
that is both hidden and a symbolic link. The included patch does just
that. I admit that this reeks of hackery, but I thought that pruning
simply on any symbolic link or simply on any hidden directory was
likely to break something that might currently rely on it working as it
does.

Thinking about this, pruning hidden directories -- turned on by default,
but disableable -- might be a good idea ; hidden directories are often
used to store private data or configuration data, or even cached data
(for example Subversion stores pristine copies of files in .svn
subdirs). I think that would be a good default behaviour. Russ, any
opinion ?

I don't have particularly strong opinions on Pod​::Html, as I've never
really looked at it in any detail, but the general idea sounds reasonable
to me.

--
Russ Allbery (rra@​stanford.edu) <http​://www.eyrie.org/~eagle/>

@p5pRT
Copy link
Author

p5pRT commented Dec 12, 2003

From ajohnson@nvidia.com

Here's the patch that implements Rafael's suggestion​:

----- perl-5.8.2-podhid.patch -----

Inline Patch
diff -Naur perl-5.8.2/lib/Pod/Html.pm perl-5.8.2-podhid/lib/Pod/Html.pm
--- perl-5.8.2/lib/Pod/Html.pm  Tue Sep 30 10:11:02 2003
+++ perl-5.8.2-podhid/lib/Pod/Html.pm   Fri Dec 12 13:35:03 2003
@@ -78,6 +78,20 @@
 
 Displays the usage message.
 
+=item hiddendirs
+
+    --hiddendirs
+    --nohiddendirs
+
+Include hidden directories in the search for POD's in podpath if recurse
+is set.
+The default is not to traverse any directory whose name begins with C<.>.
+See L</"podpath"> and L</"recurse">.
+
+[This option is for backward compatibility only.
+It's hard to imagine that one would usefully create a module with a
+name component beginning with C<.>.]
+
 =item htmldir
 
     --htmldir=name
@@ -213,6 +227,7 @@
 
 my $Recurse;
 my $Quiet;
+my $HiddenDirs;
 my $Verbose;
 my $Doindex;
 
@@ -604,6 +619,7 @@
   --flush        - flushes the item and directory caches.
   --[no]header   - produce block header/footer (default is no headers).
   --help         - prints this message.
+  --hiddendirs   - search hidden directories in podpath
   --htmldir      - directory for resulting HTML files.
   --htmlroot     - http-server base directory from which all relative paths
                    in podpath stem (default is /).
@@ -634,6 +650,7 @@
 
 sub parse_command_line {
     my
($opt_backlink,$opt_cachedir,$opt_css,$opt_flush,$opt_header,$opt_help, \+ $opt\_hiddendirs\,   $opt\_htmldir\,$opt\_htmlroot\,$opt\_index\,$opt\_infile\,$opt\_libpods\,   $opt\_netscape\,$opt\_outfile\,$opt\_podpath\,$opt\_podroot\,$opt\_quiet\,   $opt\_recurse\,$opt\_title\,$opt\_verbose\); @​@​ \-646\,6 \+663\,7 @​@​   'flush' => \\$opt\_flush\,   'header\!' => \\$opt\_header\,   'help' => \\$opt\_help\, \+ 'hiddendirs\!' => \\$opt\_hiddendirs\,   'htmldir=s' => \\$opt\_htmldir\,   'htmlroot=s' => \\$opt\_htmlroot\,   'index\!' => \\$opt\_index\, @​@​ \-676\,6 \+694\,7 @​@​   $Htmlroot = $opt\_htmlroot if defined $opt\_htmlroot;   $Doindex = $opt\_index if defined $opt\_index;   $Podfile = $opt\_infile if defined $opt\_infile; \+ $HiddenDirs = $opt\_hiddendirs if defined $opt\_hiddendirs;   $Htmlfile = $opt\_outfile if defined $opt\_outfile;   $Podroot = $opt\_podroot if defined $opt\_podroot;   $Quiet = $opt\_quiet if defined $opt\_quiet; @​@​ \-921\,7 \+940\,9 @​@​   opendir\(DIR\, $dir\) ||   die "$0​: error opening directory $dir​: $\!\\n";   while \(defined\($\_ = readdir\(DIR\)\)\) \{ \- if \(\-d "$dir/$\_" && $\_ ne "\." && $\_ ne "\.\."\) \{ \# directory \+ if \(\-d "$dir/$\_" && $\_ ne "\." && $\_ ne "\.\." && \+ \($HiddenDirs || \!/^\\\./\) \+ \) \{ \# directory   $Pages\{$\_\} = "" unless defined $Pages\{$\_\};   $Pages\{$\_\} \.= "$dir/$\_​:";   push\(@​subdirs\, $\_\);

-----Original Message-----
From​: Russ Allbery via RT [mailto​:perlbug-followup@​perl.org]
Sent​: Friday, December 12, 2003 11​:15 AM
To​: Anders Johnson
Subject​: Re​: [perl #24610] Pod​::Html infinite recursion

Rafael Garcia-Suarez <rgarciasuarez@​free.fr> writes​:

ajohnson@​nvidia.com (via RT) wrote​:

Pod​::Html will recurse forever if there is a symbolic link to a
superdirectory within a directory specified in -podpath.

(In our environment, there is a symbolic link to the "top of source
configuration" in every directory, and this has been found to be
extremely useful. However, it exposes this bug rather egregiously.)

One way to deal with this is to prune the recursion on any directory
that is both hidden and a symbolic link. The included patch does just
that. I admit that this reeks of hackery, but I thought that pruning
simply on any symbolic link or simply on any hidden directory was
likely to break something that might currently rely on it working as it
does.

Thinking about this, pruning hidden directories -- turned on by default,
but disableable -- might be a good idea ; hidden directories are often
used to store private data or configuration data, or even cached data
(for example Subversion stores pristine copies of files in .svn
subdirs). I think that would be a good default behaviour. Russ, any
opinion ?

I don't have particularly strong opinions on Pod​::Html, as I've never
really looked at it in any detail, but the general idea sounds reasonable
to me.

--
Russ Allbery (rra@​stanford.edu) <http​://www.eyrie.org/~eagle/>

@p5pRT
Copy link
Author

p5pRT commented Dec 13, 2003

From @rgs

Anders Johnson wrote​:

Here's the patch that implements Rafael's suggestion​:

----- perl-5.8.2-podhid.patch -----
diff -Naur perl-5.8.2/lib/Pod/Html.pm perl-5.8.2-podhid/lib/Pod/Html.pm
--- perl-5.8.2/lib/Pod/Html.pm Tue Sep 30 10​:11​:02 2003
+++ perl-5.8.2-podhid/lib/Pod/Html.pm Fri Dec 12 13​:35​:03 2003

Thank you very much. I've applied it to the sources of the development
version of perl, and bumped up the version number of Pod​::Html to
1.0502, as change #21884.

@p5pRT
Copy link
Author

p5pRT commented Dec 13, 2003

@rgs - Status changed from 'new' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant