]> sipb.mit.edu Git - ikiwiki.git/commitdiff
* Fix a forkbomb in various calls to IPC::Open2, which has a highly
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Mon, 25 Sep 2006 21:38:25 +0000 (21:38 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Mon, 25 Sep 2006 21:38:25 +0000 (21:38 +0000)
  braindead interface. Closes: #389383

IkiWiki/Plugin/googlecalendar.pm
IkiWiki/Plugin/htmltidy.pm
IkiWiki/Plugin/linkmap.pm
IkiWiki/Plugin/rst.pm
debian/changelog

index c6abeb717d96ca7cdc16bd3e7f15e130b2d99d55..dc0df0ad3ff6d523571366b651a8f171e3799698 100644 (file)
@@ -4,7 +4,6 @@ package IkiWiki::Plugin::googlecalendar;
 use warnings;
 use strict;
 use IkiWiki;
 use warnings;
 use strict;
 use IkiWiki;
-use IPC::Open2;
 
 sub import { #{{{
        hook(type => "preprocess", id => "googlecalendar",
 
 sub import { #{{{
        hook(type => "preprocess", id => "googlecalendar",
index 906c677dc1302391eebd9266d74aea20fe5b1d9c..0609e72c328e5ea4fc06b945203f51f73e0e6338 100644 (file)
@@ -19,21 +19,13 @@ sub import { #{{{
 sub sanitize (@) { #{{{
        my %params=@_;
 
 sub sanitize (@) { #{{{
        my %params=@_;
 
-       my $tries=10;
        my $pid;
        my $pid;
-       while (1) {
-               eval {
-                       $pid=open2(*IN, *OUT, 'tidy -quiet -asxhtml -utf8 --show-body-only yes --show-warnings no --tidy-mark no');
-               };
-               last unless $@;
-               $tries--;
-               if ($tries < 1) {
-                       debug("failed to run tidy: $@");
-                       return $params{content};
-               }
-       }
+       my $sigpipe=0;
+       $SIG{PIPE}=sub { $sigpipe=1 };
+       $pid=open2(*IN, *OUT, 'tidy -quiet -asxhtml -utf8 --show-body-only yes --show-warnings no --tidy-mark no');
+       
        # open2 doesn't respect "use open ':utf8'"
        # open2 doesn't respect "use open ':utf8'"
-       binmode (IN, ':utf8'); 
+       binmode (IN, ':utf8');
        binmode (OUT, ':utf8'); 
        
        print OUT $params{content};
        binmode (OUT, ':utf8'); 
        
        print OUT $params{content};
@@ -44,6 +36,9 @@ sub sanitize (@) { #{{{
        close IN;
        waitpid $pid, 0;
 
        close IN;
        waitpid $pid, 0;
 
+       return $params{content} if $sigpipe;
+       $SIG{PIPE}="DEFAULT";
+
        return $ret;
 } # }}}
 
        return $ret;
 } # }}}
 
index 6b16097442cc468abcdb4f88754cf498eafab2c8..497b1ef43485dbdd4cb77043072f42c4a3b2898e 100644 (file)
@@ -63,18 +63,11 @@ sub genmap ($) { #{{{
        # TODO: should really add the png to renderedfiles and call
        # check_overwrite, but currently renderedfiles
        # only supports listing one file per page.
        # TODO: should really add the png to renderedfiles and call
        # check_overwrite, but currently renderedfiles
        # only supports listing one file per page.
-       my $tries=10;
        my $pid;
        my $pid;
-       while (1) {
-               eval {
-                       $pid=open2(*IN, *OUT, "dot -Tpng -o '$config{destdir}/$params{page}.png' -Tcmapx");
-               };
-               last unless $@;
-               $tries--;
-               if ($tries < 1) {
-                       return "failed to run dot: $@";
-               }
-       }
+       my $sigpipe=0;;
+       $SIG{PIPE}=sub { $sigpipe=1 };
+       $pid=open2(*IN, *OUT, "dot -Tpng -o '$config{destdir}/$params{page}.png' -Tcmapx");
+       
        # open2 doesn't respect "use open ':utf8'"
        binmode (IN, ':utf8'); 
        binmode (OUT, ':utf8'); 
        # open2 doesn't respect "use open ':utf8'"
        binmode (IN, ':utf8'); 
        binmode (OUT, ':utf8'); 
@@ -96,12 +89,18 @@ sub genmap ($) { #{{{
 
        local $/=undef;
        my $ret="<object data=\"".
 
        local $/=undef;
        my $ret="<object data=\"".
-               IkiWiki::abs2rel("$params{page}.png", IkiWiki::dirname($params{page})).
-               "\" type=\"image/png\" usemap=\"#linkmap$mapnum\">\n".
-                <IN>.
-                "</object>";
+              IkiWiki::abs2rel("$params{page}.png", IkiWiki::dirname($params{page})).
+              "\" type=\"image/png\" usemap=\"#linkmap$mapnum\">\n".
+               <IN>.
+               "</object>";
        close IN;
        close IN;
+       
        waitpid $pid, 0;
        waitpid $pid, 0;
+       $SIG{PIPE}="DEFAULT";
+       if ($sigpipe) {
+               return  "[[linkmap failed to run dot]]";
+       }
+
        return $ret;
 } #}}}
 
        return $ret;
 } #}}}
 
index 1fd13d1f5ceca92262cbbfb70d86e979c9ff7d88..afd60f6687d5e759321cb42261fb1a48a3241094 100644 (file)
@@ -43,21 +43,11 @@ sub htmlize (@) { #{{{
        my %params=@_;
        my $content=$params{content};
 
        my %params=@_;
        my $content=$params{content};
 
-       my $tries=10;
        my $pid;
        my $pid;
-       while (1) {
-               eval {
-                       # Try to call python and run our command
-                       $pid=open2(*IN, *OUT, "python", "-c",  $pyCmnd)
-                               or return $content;
-               };
-               last unless $@;
-               $tries--;
-               if ($tries < 1) {
-                       debug("failed to run python to convert rst: $@");
-                       return $content;
-               }
-       }
+       my $sigpipe=0;
+       $SIG{PIPE}=sub { $sigpipe=1 };
+       $pid=open2(*IN, *OUT, "python", "-c",  $pyCmnd);
+       
        # open2 doesn't respect "use open ':utf8'"
        binmode (IN, ':utf8');
        binmode (OUT, ':utf8');
        # open2 doesn't respect "use open ':utf8'"
        binmode (IN, ':utf8');
        binmode (OUT, ':utf8');
@@ -70,6 +60,9 @@ sub htmlize (@) { #{{{
        close IN;
        waitpid $pid, 0;
 
        close IN;
        waitpid $pid, 0;
 
+       return $content if $sigpipe;
+       $SIG{PIPE}="DEFAULT";
+
        return $ret;
 } # }}}
 
        return $ret;
 } # }}}
 
index a4f06fa64eba12d984d663203571e92b79effffd..7bc31654318e9dfff07404d6b6f24f157ca91e72 100644 (file)
@@ -2,8 +2,10 @@ ikiwiki (1.28) UNRELEASED; urgency=low
 
   * inline: Add ability to sort by page name, based on a patch from
     Benjamin A'Lee.
 
   * inline: Add ability to sort by page name, based on a patch from
     Benjamin A'Lee.
+  * Fix a forkbomb in various calls to IPC::Open2, which has a highly
+    braindead interface. Closes: #389383
 
 
- -- Joey Hess <joeyh@debian.org>  Mon, 25 Sep 2006 17:06:39 -0400
+ -- Joey Hess <joeyh@debian.org>  Mon, 25 Sep 2006 17:22:52 -0400
 
 ikiwiki (1.27) unstable; urgency=low
 
 
 ikiwiki (1.27) unstable; urgency=low