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

12 files changed:
Bugzilla/Attachment.pm
Bugzilla/Attachment/PatchReader.pm
Bugzilla/Config/Common.pm
Bugzilla/Error.pm
Bugzilla/Install/CPAN.pm
Bugzilla/Install/Filesystem.pm
Bugzilla/Send/Sendmail.pm
collectstats.pl
reports.cgi
search_plugin.cgi
showdependencygraph.cgi
testserver.pl

index 97cd85008b69a8685c309cf4e2b63938a3e0f4b2..cd8316a9161a9431c8d7bdaef7c4a81cb1002cd6 100644 (file)
@@ -342,7 +342,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>;
@@ -388,7 +388,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 4026ba7393d4809a519d60d577e49820676ededb..e75a660f269af48de236fb65ac3adc238400a125 100644 (file)
@@ -99,7 +99,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 b69ccb543230c97e7646ea89f3caccb6bca5302d..e1c2c8c4094cf575bf75102a5394ba34ddc52c69 100644 (file)
@@ -231,7 +231,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 cebc2a4ac0dc996a19a909803c596889e2eb37b1..32c7715b44e71d369ba4191b9f231fee2e327d9d 100644 (file)
@@ -71,7 +71,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 f96bb4cb97d515e8dc3a1018a32442e60a4f25a5..8a880df8041f401c104cc8205d0e170b2f224ace 100644 (file)
@@ -203,8 +203,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 cf61a6ec25d43a91d8942f4a5867395095893ffa..aac447e287990b2893edcf707e12cf57616b859e 100644 (file)
@@ -574,7 +574,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 9513134f4432774d80c7625b923fa97bedb46fb1..012cd6f282c60f7d772ca9cf865fd8a17ab70ca7 100644 (file)
@@ -29,7 +29,7 @@ sub send {
 
     my $pipe = gensym;
 
-    open($pipe, "| $mailer -t -oi @args")
+    open($pipe, "|-", "$mailer -t -oi @args")
         || return failure "Error executing $mailer: $!";
     print($pipe $message->as_string)
         || return failure "Error printing via pipe to $mailer: $!";
index aa98ddfb439bfd888931f54fa4ca115ba03085a0..d2b6b74d3cc94c0340df9a55adc5c423183de48e 100755 (executable)
@@ -321,7 +321,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 a2e1e6a7e339029abbaf9aff34b6f3dd4687db9e..7b7c59478ad6e2a6cb4b0533e157b4231d6427cb 100755 (executable)
@@ -136,7 +136,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 3809159c723d5bef16751137c43fe411743ff920..ca515bfae8d5afa37e4a2337fc8c2b06c8877cdf 100755 (executable)
@@ -24,7 +24,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 8e3592fbe56f5272f7afa8a700f8a1f3983683a2..4187bdd4e4dc35db0d3ce59b43fc32a6321209c9 100755 (executable)
@@ -46,7 +46,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};
@@ -247,7 +247,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;
@@ -276,7 +276,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 77489d252f74e48cb3bcff6c559ecf4fa19f220e..12cdfe5f02ce8ff3913d5e27f72338793452f34f 100755 (executable)
@@ -37,7 +37,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;
@@ -264,7 +264,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;
@@ -273,7 +273,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>;