summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Lawrence <dkl@mozilla.com>2015-01-27 05:27:50 +0100
committerByron Jones <glob@mozilla.com>2015-01-27 05:27:50 +0100
commit90244813fe8110fc91f3746ebd93880e1c911cf1 (patch)
tree34ff732e860855956f043d0a41db8b2f30ef0095
parenta748745d3eb9110b0c6bcd803d8d86db8951ad43 (diff)
downloadbugzilla-90244813fe8110fc91f3746ebd93880e1c911cf1.tar.gz
bugzilla-90244813fe8110fc91f3746ebd93880e1c911cf1.tar.xz
Bug 1124432: Backport upstream bug 1079065 to bmo/4.2 to fix improper use of open() calls
-rw-r--r--Bugzilla/Attachment.pm4
-rw-r--r--Bugzilla/Config/Common.pm2
-rw-r--r--Bugzilla/Error.pm2
-rw-r--r--Bugzilla/Install/CPAN.pm4
-rw-r--r--Bugzilla/Install/Filesystem.pm2
-rw-r--r--Bugzilla/PatchReader/AddCVSContext.pm2
-rw-r--r--Bugzilla/PatchReader/Raw.pm2
-rw-r--r--Bugzilla/Send/Sendmail.pm2
-rwxr-xr-xcollectstats.pl2
-rw-r--r--extensions/Push/lib/Connector/TCL.pm2
-rw-r--r--extensions/Push/lib/Daemon.pm6
-rwxr-xr-xmetrics.pl6
-rwxr-xr-xreports.cgi2
-rwxr-xr-xsentry.pl6
-rwxr-xr-xshowdependencygraph.cgi6
-rwxr-xr-xtestserver.pl6
16 files changed, 28 insertions, 28 deletions
diff --git a/Bugzilla/Attachment.pm b/Bugzilla/Attachment.pm
index 33a4c55a5..8361c1cce 100644
--- a/Bugzilla/Attachment.pm
+++ b/Bugzilla/Attachment.pm
@@ -344,7 +344,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>;
@@ -390,7 +390,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);
diff --git a/Bugzilla/Config/Common.pm b/Bugzilla/Config/Common.pm
index edd5872e1..35a70994b 100644
--- a/Bugzilla/Config/Common.pm
+++ b/Bugzilla/Config/Common.pm
@@ -257,7 +257,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";
}
diff --git a/Bugzilla/Error.pm b/Bugzilla/Error.pm
index 6e3309778..8c6888b49 100644
--- a/Bugzilla/Error.pm
+++ b/Bugzilla/Error.pm
@@ -87,7 +87,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;
}
diff --git a/Bugzilla/Install/CPAN.pm b/Bugzilla/Install/CPAN.pm
index 31bd7f88f..e6afa1f3b 100644
--- a/Bugzilla/Install/CPAN.pm
+++ b/Bugzilla/Install/CPAN.pm
@@ -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);
diff --git a/Bugzilla/Install/Filesystem.pm b/Bugzilla/Install/Filesystem.pm
index 2b7e3781c..5d4d84f88 100644
--- a/Bugzilla/Install/Filesystem.pm
+++ b/Bugzilla/Install/Filesystem.pm
@@ -644,7 +644,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
diff --git a/Bugzilla/PatchReader/AddCVSContext.pm b/Bugzilla/PatchReader/AddCVSContext.pm
index 910e45669..e4100afb1 100644
--- a/Bugzilla/PatchReader/AddCVSContext.pm
+++ b/Bugzilla/PatchReader/AddCVSContext.pm
@@ -190,7 +190,7 @@ sub push_context_lines {
if (Bugzilla::PatchReader::CVSClient::cvs_co_rev($this->{CVSROOT}, $this->{REVISION}, $this->{FILENAME})) {
die "Could not check out $this->{FILENAME} r$this->{REVISION} from $this->{CVSROOT}";
}
- open my $fh, $this->{FILENAME} or die "Could not open $this->{FILENAME}";
+ open(my $fh, '<', $this->{FILENAME}) or die "Could not open $this->{FILENAME}";
$this->{FILE} = $fh;
$this->{NEXT_FILE_LINE} = 1;
trick_taint($olddir); # $olddir comes from getcwd()
diff --git a/Bugzilla/PatchReader/Raw.pm b/Bugzilla/PatchReader/Raw.pm
index b58ed3a2d..7e34bd4bf 100644
--- a/Bugzilla/PatchReader/Raw.pm
+++ b/Bugzilla/PatchReader/Raw.pm
@@ -234,7 +234,7 @@ sub iterate_file {
my $this = shift;
my ($filename) = @_;
- open FILE, $filename or die "Could not open $filename: $!";
+ open(FILE, '<', $filename) or die "Could not open $filename: $!";
$this->start_lines($filename);
while (<FILE>) {
$this->next_line($_);
diff --git a/Bugzilla/Send/Sendmail.pm b/Bugzilla/Send/Sendmail.pm
index 9513134f4..0c3cfe9e4 100644
--- a/Bugzilla/Send/Sendmail.pm
+++ b/Bugzilla/Send/Sendmail.pm
@@ -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: $!";
diff --git a/collectstats.pl b/collectstats.pl
index c5db30b5f..267685117 100755
--- a/collectstats.pl
+++ b/collectstats.pl
@@ -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
diff --git a/extensions/Push/lib/Connector/TCL.pm b/extensions/Push/lib/Connector/TCL.pm
index 16ebb0319..25e5750dc 100644
--- a/extensions/Push/lib/Connector/TCL.pm
+++ b/extensions/Push/lib/Connector/TCL.pm
@@ -267,7 +267,7 @@ sub _get_bug_data {
sub _write_file {
my ($filename, $content) = @_;
- open(my $fh, ">$filename") or die "Failed to write to $filename: $!\n";
+ open(my $fh, ">", $filename) or die "Failed to write to $filename: $!\n";
binmode($fh);
print $fh $content;
close($fh) or die "Failed to write to $filename: $!\n";
diff --git a/extensions/Push/lib/Daemon.pm b/extensions/Push/lib/Daemon.pm
index 66e15783e..c8472e450 100644
--- a/extensions/Push/lib/Daemon.pm
+++ b/extensions/Push/lib/Daemon.pm
@@ -69,12 +69,12 @@ sub gd_redirect_output {
my $self = shift;
my $filename = bz_locations()->{datadir} . '/' . $self->{gd_progname} . ".log";
- open(STDERR, ">>$filename") or (print "could not open stderr: $!" && exit(1));
+ open(STDERR, ">>", $filename) or (print "could not open stderr: $!" && exit(1));
close(STDOUT);
- open(STDOUT, ">&STDERR") or die "redirect STDOUT -> STDERR: $!";
+ open(STDOUT, ">&", STDERR) or die "redirect STDOUT -> STDERR: $!";
$SIG{HUP} = sub {
close(STDERR);
- open(STDERR, ">>$filename") or (print "could not open stderr: $!" && exit(1));
+ open(STDERR, ">>", $filename) or (print "could not open stderr: $!" && exit(1));
};
}
diff --git a/metrics.pl b/metrics.pl
index f10499057..c48629c45 100755
--- a/metrics.pl
+++ b/metrics.pl
@@ -35,9 +35,9 @@ eval "use $reporter_class";
# detach
if ($reporter_class->DETACH) {
- open(STDIN, '</dev/null');
- open(STDOUT, '>/dev/null');
- open(STDERR, '>/dev/null');
+ open(STDIN, '<', '/dev/null');
+ open(STDOUT, '>', '/dev/null');
+ open(STDERR, '>', '/dev/null');
setsid();
}
diff --git a/reports.cgi b/reports.cgi
index 01bbb50c7..7009d2973 100755
--- a/reports.cgi
+++ b/reports.cgi
@@ -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 = '';
}
diff --git a/sentry.pl b/sentry.pl
index 5c93e6ee3..9b37694d8 100755
--- a/sentry.pl
+++ b/sentry.pl
@@ -40,9 +40,9 @@ Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
nice(19);
# detach
-open(STDIN, '</dev/null');
-open(STDOUT, '>/dev/null');
-open(STDERR, '>/dev/null');
+open(STDIN, '<', '/dev/null');
+open(STDOUT, '>', '/dev/null');
+open(STDERR, '>', '/dev/null');
setsid();
# grab sentry server url
diff --git a/showdependencygraph.cgi b/showdependencygraph.cgi
index ed657dc12..4fc1b9386 100755
--- a/showdependencygraph.cgi
+++ b/showdependencygraph.cgi
@@ -62,7 +62,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};
@@ -267,7 +267,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;
@@ -296,7 +296,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;
diff --git a/testserver.pl b/testserver.pl
index 3142685bc..ffe4b1ad5 100755
--- a/testserver.pl
+++ b/testserver.pl
@@ -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>;