]> 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 19:49:57 +0000 (19:49 +0000)
committerDavid Lawrence <dkl@mozilla.com>
Wed, 21 Jan 2015 19:49:57 +0000 (19:49 +0000)
r=dylan,a=simon

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

index e165b139e603148ccdaf9aabd53c2722a955b722..ed770ad894c739219357aaa3f894158ff05664ea 100644 (file)
@@ -333,7 +333,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())) {
             # file is actually on disk.
             $self->{is_on_filesystem} = 1;
             local $/;
@@ -412,7 +412,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())) {
             # file is actually on disk.
             $self->{is_on_filesystem} = 1;
             binmode AH;
index 05a7ce7b3a7caffba28af9f195ecff54819325a4..ef6320d1595c0bbd566afca02e16039e86f1c30f 100644 (file)
@@ -74,7 +74,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 19f14319083ba79febd23fbd4b9acd6d3478229d..094784e1a4b7771ea77f1fe223a388642a092382 100644 (file)
@@ -196,8 +196,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 2120cbc573a1392a6194083d9abfada3ad920b4a..64b651c62e94eb5bd60399cf13ae5aa163d6f7c6 100644 (file)
@@ -634,7 +634,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 3473c9e71896d5d9a1f1bb890e923076c53e13a4..339e428bc3daa5b9465261fdf09639e16d411d9f 100755 (executable)
@@ -309,7 +309,7 @@ sub regenerate_stats {
         return;
     }
 
-    if (open DATA, ">$file") {
+    if (open DATA, ">", $file) {
         my $fields = join('|', ('DATE', @statuses, @resolutions));
         my $product_name = $product->name;
         print DATA <<FIN;
index cdc9d4a87d89eaa24bab0faed2b390aff1760f05..89dee1c9a5361f6160917a648bf420761a6ebd55 100755 (executable)
@@ -138,7 +138,7 @@ sub generate_chart {
     my ($dir, $image_file, $product, $datasets) = @_;
     my $data_file = $dir . '/' . $product->id;
 
-    if (! open FILE, $data_file) {
+    if (!open(FILE, '<', $data_file)) {
         ThrowCodeError('chart_data_not_generated', {'product' => $product});
     }
 
index 7de8bed5f7e0615e43c541a7dc20822d72c8d8bf..0b628f32ef26fc7a68cd9700c8a98371cb2185ce 100755 (executable)
@@ -27,7 +27,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 528b9cd61909c76d8cb7324548f8796e41e86bd3..d93c1c875d031688c7eb9b13c036c7c0b84340b7 100755 (executable)
@@ -49,7 +49,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};
@@ -258,7 +258,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;
@@ -287,7 +287,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 2ab48f3751738524898ec01917ce10dc83ebb7d0..d827c80ea2ac2f159d7873bd151e9952a016a6fe 100755 (executable)
@@ -40,7 +40,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;
@@ -267,7 +267,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;
@@ -276,7 +276,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>;