]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1079065: [SECURITY] Always use the 3 arguments form for open() to prevent shell...
authorGervase Markham <gerv@mozilla.org>
Wed, 21 Jan 2015 20:26:39 +0000 (20:26 +0000)
committerDavid Lawrence <dkl@mozilla.com>
Wed, 21 Jan 2015 20:26:39 +0000 (20:26 +0000)
r=dylan,a=simon

Bugzilla/Attachment.pm
Bugzilla/Attachment/PatchReader.pm
Bugzilla/Config/Common.pm
Bugzilla/Error.pm
Bugzilla/Install/CPAN.pm
Bugzilla/Install/Filesystem.pm
collectstats.pl
reports.cgi
search_plugin.cgi
showdependencygraph.cgi
testserver.pl

index fa8845358b3e015cba5a8e7fd325932a3367e972..6d90bed2b2315f801e6960eb7abc45eca5fb99a6 100644 (file)
@@ -359,7 +359,7 @@ sub data {
     # If there's no attachment data in the database, the attachment is stored
     # in a local file, so retrieve it from there.
     if (length($self->{data}) == 0) {
-        if (open(AH, $self->_get_local_filename())) {
+        if (open(AH, '<', $self->_get_local_filename())) {
             local $/;
             binmode AH;
             $self->{data} = <AH>;
@@ -405,7 +405,7 @@ sub datasize {
     # is stored in a local file, and so retrieve its size from the file,
     # or the attachment has been deleted.
     unless ($self->{datasize}) {
-        if (open(AH, $self->_get_local_filename())) {
+        if (open(AH, '<', $self->_get_local_filename())) {
             binmode AH;
             $self->{datasize} = (stat(AH))[7];
             close(AH);
index cfc7610f4029c5e4348081f812c2b3dc16abbfba..782251d1421d39f101a487ea15086527d587f516 100644 (file)
@@ -109,7 +109,7 @@ sub process_interdiff {
     # Send through interdiff, send output directly to template.
     # Must hack path so that interdiff will work.
     $ENV{'PATH'} = $lc->{diffpath};
-    open my $interdiff_fh, "$lc->{interdiffbin} $old_filename $new_filename|";
+    open my $interdiff_fh, '-|', "$lc->{interdiffbin} $old_filename $new_filename";
     binmode $interdiff_fh;
     my ($reader, $last_reader) = setup_patch_readers("", $context);
 
index 00c699217b65c958deb0cebc73ef045ac3f1f1a3..385f1ce81ac0ebeeca9a5d0ba58bb42da278c623 100644 (file)
@@ -256,7 +256,7 @@ sub check_webdotbase {
         # Check .htaccess allows access to generated images
         my $webdotdir = bz_locations()->{'webdotdir'};
         if(-e "$webdotdir/.htaccess") {
-            open HTACCESS, "$webdotdir/.htaccess";
+            open HTACCESS, "<", "$webdotdir/.htaccess";
             if(! grep(/ \\\.png\$/,<HTACCESS>)) {
                 return "Dependency graph images are not accessible.\nAssuming that you have not modified the file, delete $webdotdir/.htaccess and re-run checksetup.pl to rectify.\n";
             }
index 178f6f90cfb1351802bfa4c58771520e0704d074..871edbf36eda144ae4d3da8a2327068ff9ed2c9c 100644 (file)
@@ -86,7 +86,7 @@ sub _throw_error {
             $val = "*****" if $val =~ /password|http_pass/i;
             $mesg .= "[$$] " . Data::Dumper->Dump([$val],["env($var)"]);
         }
-        open(ERRORLOGFID, ">>$datadir/errorlog");
+        open(ERRORLOGFID, ">>", "$datadir/errorlog");
         print ERRORLOGFID "$mesg\n";
         close ERRORLOGFID;
     }
index 31bd7f88fb303ef66413fc64ac0a5398da79faf9..e6afa1f3b9c201f5490f9e2c93cfdebc40084d60 100644 (file)
@@ -222,8 +222,8 @@ sub set_cpan_config {
     # Calling a senseless autoload that does nothing makes us
     # automatically load any existing configuration.
     # We want to avoid the "invalid command" message.
-    open(my $saveout, ">&STDOUT");
-    open(STDOUT, '>/dev/null');
+    open(my $saveout, ">&", "STDOUT");
+    open(STDOUT, '>', '/dev/null');
     eval { CPAN->ignore_this_error_message_from_bugzilla; };
     undef $@;
     close(STDOUT);
index c5215ecfaca1eee229a5af867d76e934729e2feb..27e5a1b49be03e0479870ef6a2f320d4a443e456 100644 (file)
@@ -583,7 +583,7 @@ sub _update_old_charts {
                  ($in_file =~ /\.orig$/i));
 
         rename("$in_file", "$in_file.orig") or next;
-        open(IN, "$in_file.orig") or next;
+        open(IN, "<", "$in_file.orig") or next;
         open(OUT, '>', $in_file) or next;
 
         # Fields in the header
index 1487e5a72e8cca992df1f1cbf3e6f112fca95907..8d7fcdda1b9e2431ac9e456b34bc4a61df48f185 100755 (executable)
@@ -340,7 +340,7 @@ sub regenerate_stats {
         return;
     }
 
-    if (open DATA, ">$file") {
+    if (open DATA, ">", $file) {
         my $fields = join('|', ('DATE', @statuses, @resolutions));
         print DATA <<FIN;
 # Bugzilla Daily Bug Stats
index 01bbb50c7fad5721efda7fde72b08ff730a2417f..7009d29731dcb3b1dd25ff20c9e489a433d5bc6d 100755 (executable)
@@ -160,7 +160,7 @@ sub generate_chart {
     $data_file =~ s/\//-/gs;
     $data_file = $dir . '/' . $data_file;
 
-    if (! open FILE, $data_file) {
+    if (!open(FILE, '<', $data_file)) {
         if ($product eq '-All-') {
             $product = '';
         }
index 4dfe8fa9f4d3e3c5307e6934a10caf90e5bdc2c4..6040d02267f1c465711243c242b7784a1159e716 100755 (executable)
@@ -33,7 +33,7 @@ print $cgi->header('application/xml');
 
 # Get the contents of favicon.ico
 my $filename = bz_locations()->{'libpath'} . "/images/favicon.ico";
-if (open(IN, $filename)) {
+if (open(IN, '<', $filename)) {
     local $/;
     binmode IN;
     $vars->{'favicon'} = <IN>;
index 71eaa91834418de242b3c9c20e20bba0f0757034..a461187fa5e9bbf881b38e2b4855ce0d91c26fee 100755 (executable)
@@ -61,7 +61,7 @@ sub CreateImagemap {
     my $map = "<map name=\"imagemap\">\n";
     my $default = "";
 
-    open MAP, "<$mapfilename";
+    open MAP, "<", $mapfilename;
     while(my $line = <MAP>) {
         if($line =~ /^default ([^ ]*)(.*)$/) {
             $default = qq{<area alt="" shape="default" href="$1">\n};
@@ -259,7 +259,7 @@ if ($webdotbase =~ /^https?:/) {
                                                  error => $! });
 
     binmode $pngfh;
-    open(DOT, "\"$webdotbase\" -Tpng $filename|");
+    open(DOT, '-|', "\"$webdotbase\" -Tpng $filename");
     binmode DOT;
     print $pngfh $_ while <DOT>;
     close DOT;
@@ -288,7 +288,7 @@ if ($webdotbase =~ /^https?:/) {
                                                  error => $! });
 
     binmode $mapfh;
-    open(DOT, "\"$webdotbase\" -Tismap $filename|");
+    open(DOT, '-|', "\"$webdotbase\" -Tismap $filename");
     binmode DOT;
     print $mapfh $_ while <DOT>;
     close DOT;
index 3142685bc9b68646fdb0751fdb44cb2b30cdc1fe..ffe4b1ad5b3440a2945df358e548207bbd5c4aaf 100755 (executable)
@@ -44,7 +44,7 @@ my @pscmds = ('ps -eo comm,gid', 'ps -acxo command,gid', 'ps -acxo command,rgid'
 my $sgid = 0;
 if (!ON_WINDOWS) {
     foreach my $pscmd (@pscmds) {
-        open PH, "$pscmd 2>/dev/null |";
+        open PH, '-|', "$pscmd 2>/dev/null";
         while (my $line = <PH>) {
             if ($line =~ /^(?:\S*\/)?(?:httpd|apache)2?\s+(\d+)$/) {
                 $sgid = $1 if $1 > $sgid;
@@ -271,7 +271,7 @@ sub check_image {
 
 sub create_file {
     my ($filename, $content) = @_;
-    open(FH, ">$filename")
+    open(FH, ">", $filename)
         or die "Failed to create $filename: $!\n";
     binmode FH;
     print FH $content;
@@ -280,7 +280,7 @@ sub create_file {
 
 sub read_file {
     my ($filename) = @_;
-    open(FH, $filename)
+    open(FH, "<", $filename)
         or die "Failed to open $filename: $!\n";
     binmode FH;
     my $content = <FH>;