Skip to content

Commit

Permalink
use 3 parameters in open
Browse files Browse the repository at this point in the history
  • Loading branch information
bigio committed May 31, 2022
1 parent 58eb14b commit 3e0a7fb
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion gen-ip-validator.pl
Expand Up @@ -27,7 +27,7 @@ ($)
my $junk;

if (-r "/dev/urandom") {
open(IN, "</dev/urandom");
open(IN, "<", "/dev/urandom");
read(IN, $junk, $len);
close(IN);
}
Expand Down
8 changes: 4 additions & 4 deletions mimedefang.pl.in
Expand Up @@ -323,7 +323,7 @@ sub main {
}

$ValidateIPHeader = "";
if (open(IN, '<@CONFDIR_EVAL@/mimedefang-ip-key')) {
if (open(IN, '<', '@CONFDIR_EVAL@/mimedefang-ip-key')) {
$ValidateIPHeader = <IN>;
chomp($ValidateIPHeader);
close(IN);
Expand Down Expand Up @@ -840,7 +840,7 @@ sub do_scan {
$parser->filer($filer);

# Parse the input stream:
if (!open(FILE, $file)) {
if (!open(FILE, '<', $file)) {
fatal("couldn't open $file: $!");
signal_complete();
return -1;
Expand Down Expand Up @@ -987,7 +987,7 @@ sub do_scan {
}

if ($Changed || $Rebuild) {
if (!open(OUT, ">NEWBODY")) {
if (!open(OUT, ">", "NEWBODY")) {
fatal("Can't open NEWBODY: $!");
signal_complete();
return -1;
Expand Down Expand Up @@ -1102,7 +1102,7 @@ sub read_commands_file {
my $needF = shift;
$needF = 0 unless defined($needF);

if (!open(IN, "<COMMANDS")) {
if (!open(IN, "<", "COMMANDS")) {
fatal("Cannot open COMMANDS file from mimedefang: $!");
return 0;
}
Expand Down
10 changes: 5 additions & 5 deletions modules/lib/Mail/MIMEDefang.pm
Expand Up @@ -876,7 +876,7 @@ sub send_quarantine_notifications {
my $donemsg = 0;
my $i;
for ($i=0; $i<=$QuarantineCount; $i++) {
if (open(IN, "<$QuarantineSubdir/MSG.$i")) {
if (open(IN, "<", "$QuarantineSubdir/MSG.$i")) {
if (!$donemsg) {
$body .= "Quarantine Messages:\n";
$donemsg = 1;
Expand All @@ -891,15 +891,15 @@ sub send_quarantine_notifications {
$body .= "\n";
}

if (open(IN, "<$QuarantineSubdir/HEADERS")) {
if (open(IN, "<", "$QuarantineSubdir/HEADERS")) {
$body .= "\n----------\nHere are the message headers:\n";
while(<IN>) {
$body .= $_;
}
close(IN);
}
for ($i=1; $i<=$QuarantineCount; $i++) {
if (open(IN, "<$QuarantineSubdir/PART.$i.HEADERS")) {
if (open(IN, "<", "$QuarantineSubdir/PART.$i.HEADERS")) {
$body .= "\n----------\nHere are the headers for quarantined part $i:\n";
while(<IN>) {
$body .= $_;
Expand Down Expand Up @@ -954,7 +954,7 @@ sub signal_complete {
}
$body .= "\n\n";
}
if (open(FILE, "<NOTIFICATION")) {
if (open(FILE, "<", "NOTIFICATION")) {
unless($NotifyNoPreamble) {
$body .= "Here are the details of the modification:\n\n";
}
Expand All @@ -969,7 +969,7 @@ sub signal_complete {
# Send notification to administrator, if required
if (-r "ADMIN_NOTIFICATION") {
my $body = "";
if (open(FILE, "<ADMIN_NOTIFICATION")) {
if (open(FILE, "<", "ADMIN_NOTIFICATION")) {
$body .= join('', <FILE>);
close(FILE);
send_admin_mail($NotifyAdministratorSubject, $body);
Expand Down
26 changes: 13 additions & 13 deletions modules/lib/Mail/MIMEDefang/Actions.pm
Expand Up @@ -310,7 +310,7 @@ sub action_delete_all_headers {
$header .= ":";
$header = lc($header);

return undef unless(open(HDRS, "<HEADERS"));
return undef unless(open(HDRS, "<", "HEADERS"));

$count = 0;
while(<HDRS>) {
Expand Down Expand Up @@ -646,13 +646,13 @@ sub action_quarantine {
copy_or_link($body->path, "$QuarantineSubdir/PART.$QuarantineCount.BODY");

# Save the part's headers
if (open(OUT, ">$QuarantineSubdir/PART.$QuarantineCount.HEADERS")) {
if (open(OUT, ">", "$QuarantineSubdir/PART.$QuarantineCount.HEADERS")) {
$entity->head->print(\*OUT);
close(OUT);
}

# Save the messages
if (open(OUT, ">$QuarantineSubdir/MSG.$QuarantineCount")) {
if (open(OUT, ">", "$QuarantineSubdir/MSG.$QuarantineCount")) {
print OUT "$msg\n";
close(OUT);
}
Expand Down Expand Up @@ -722,16 +722,16 @@ sub get_quarantine_dir {
}

# Write the sender and recipient info
if (open(OUT, ">$QuarantineSubdir/SENDER")) {
if (open(OUT, ">", "$QuarantineSubdir/SENDER")) {
print OUT "$Sender\n";
close(OUT);
}
if (open(OUT, ">$QuarantineSubdir/SENDMAIL-QID")) {
if (open(OUT, ">", "$QuarantineSubdir/SENDMAIL-QID")) {
print OUT "$QueueID\n";
close(OUT);
}

if (open(OUT, ">$QuarantineSubdir/RECIPIENTS")) {
if (open(OUT, ">", "$QuarantineSubdir/RECIPIENTS")) {
my($s);
foreach $s (@Recipients) {
print OUT "$s\n";
Expand All @@ -740,8 +740,8 @@ sub get_quarantine_dir {
}

# Copy message headers
if (open(OUT, ">$QuarantineSubdir/HEADERS")) {
if (open(IN, "<HEADERS")) {
if (open(OUT, ">", "$QuarantineSubdir/HEADERS")) {
if (open(IN, "<", "HEADERS")) {
while(<IN>) {
print OUT;
}
Expand Down Expand Up @@ -786,7 +786,7 @@ sub action_quarantine_entire_message {

$Actions{'quarantine_entire_message'}++;
if (defined($msg) && ($msg ne "")) {
if (open(OUT, ">$QuarantineSubdir/MSG.0")) {
if (open(OUT, ">", "$QuarantineSubdir/MSG.0")) {
print OUT "$msg\n";
close(OUT);
}
Expand Down Expand Up @@ -885,7 +885,7 @@ sub action_notify_sender {
return 0;
}

if (open(FILE, ">>NOTIFICATION")) {
if (open(FILE, ">>", "NOTIFICATION")) {
print FILE $msg;
close(FILE);
$Actions{'notify_sender'}++;
Expand Down Expand Up @@ -917,7 +917,7 @@ sub action_notify_administrator {
send_admin_mail($NotifyAdministratorSubject, $msg);
return 1;
}
if (open(FILE, ">>ADMIN_NOTIFICATION")) {
if (open(FILE, ">>", "ADMIN_NOTIFICATION")) {
print FILE $msg;
close(FILE);
$Actions{'notify_administrator'}++;
Expand Down Expand Up @@ -1056,7 +1056,7 @@ sub action_replace_with_url {
return 0 unless defined($entity->bodyhandle);
$path = $entity->bodyhandle->path;
return 0 unless defined($path);
open(IN, "<$path") or return 0;
open(IN, "<", "$path") or return 0;

$ctx = Digest::SHA->new;
$ctx->addfile(*IN);
Expand Down Expand Up @@ -1089,7 +1089,7 @@ sub action_replace_with_url {

# save optional Content-Disposition data
if (defined($cd_data) and ($cd_data ne "")) {
if (open CDF, ">$doc_root/.$name") {
if (open CDF, ">", "$doc_root/.$name") {
print CDF $cd_data;
close CDF;
chmod 0644, "$doc_root/.$name";
Expand Down
2 changes: 1 addition & 1 deletion modules/lib/Mail/MIMEDefang/Antispam.pm
Expand Up @@ -203,7 +203,7 @@ sub spam_assassin_mail {
return undef;
}

open(IN, "<./INPUTMSG") or return undef;
open(IN, "<", "./INPUTMSG") or return undef;
my @msg = <IN>;
close(IN);

Expand Down
4 changes: 2 additions & 2 deletions modules/lib/Mail/MIMEDefang/Antivirus.pm
Expand Up @@ -893,7 +893,7 @@ sub scan_file_using_carrier_scan {
$sock->close;
return (999, 'swerr', 'tempfail');
}
unless(open(IN, "<$fname")) {
unless(open(IN, "<", "$fname")) {
md_syslog('warning', "Cannot open $fname: $!");
$sock->close;
return(999, 'swerr', 'tempfail');
Expand Down Expand Up @@ -3010,7 +3010,7 @@ sub run_virus_scanner {
$retcode = $? / 256;

# Some daemons are instructed to save output in a file
if (open(REPORT, "DAEMON.RPT")) {
if (open(REPORT, "<", "DAEMON.RPT")) {
while(<REPORT>) {
$msg .= $_ if /$match/i;
}
Expand Down
10 changes: 5 additions & 5 deletions modules/lib/Mail/MIMEDefang/MIME.pm
Expand Up @@ -167,7 +167,7 @@ sub append_to_part {
return 0 unless defined($part->bodyhandle);
my($path) = $part->bodyhandle->path;
return 0 unless (defined($path));
return 0 unless (open(OUT, ">>$path"));
return 0 unless (open(OUT, ">>", "$path"));
print OUT "\n$boilerplate\n";
close(OUT);
$Changed = 1;
Expand Down Expand Up @@ -295,8 +295,8 @@ sub append_to_html_part {
return 0 unless defined($part->bodyhandle);
my($path) = $part->bodyhandle->path;
return 0 unless (defined($path));
return 0 unless (open(IN, "<$path"));
if (!open(OUT, ">$path.tmp")) {
return 0 unless (open(IN, "<", "$path"));
if (!open(OUT, ">", "$path.tmp")) {
close(IN);
return(0);
}
Expand Down Expand Up @@ -503,8 +503,8 @@ sub _anonymize_html_uri {
return 0 unless defined($part->bodyhandle);
my($path) = $part->bodyhandle->path;
return 0 unless (defined($path));
return 0 unless (open(IN, "<$path"));
if (!open(OUT, ">$path.tmp")) {
return 0 unless (open(IN, "<", "$path"));
if (!open(OUT, ">", "$path.tmp")) {
close(IN);
return(0);
}
Expand Down
4 changes: 2 additions & 2 deletions modules/lib/Mail/MIMEDefang/Mail.pm
Expand Up @@ -95,7 +95,7 @@ sub resend_message_specifying_mode {
}

if ($pid) { # In the parent -- pipe mail message to the child
unless (open(IN, "<INPUTMSG")) {
unless (open(IN, "<", "INPUTMSG")) {
md_syslog('err', "Could not open INPUTMSG in resend_message: $!");
return 0;
}
Expand Down Expand Up @@ -221,7 +221,7 @@ sub pretty_print_mail {
return $chunk unless (defined($body));
my($path) = $body->path;
return $chunk unless (defined($path));
return $chunk unless (open(IN, "<$path"));
return $chunk unless (open(IN, "<", "$path"));
while (<IN>) {
$chunk .= $_;
last if (length($chunk) >= $size);
Expand Down
8 changes: 4 additions & 4 deletions modules/lib/Mail/MIMEDefang/Utils.pm
Expand Up @@ -147,8 +147,8 @@ sub copy_or_link {
return 1 if link($src, $dst);

# Link failed; do it the hard way
open(IN, "<$src") or return 0;
if (!open(OUT, ">$dst")) {
open(IN, "<", "$src") or return 0;
if (!open(OUT, ">", "$dst")) {
close(IN);
return 0;
}
Expand Down Expand Up @@ -434,8 +434,8 @@ as a valid mbox file.
#***********************************************************************
sub md_copy_orig_msg_to_work_dir_as_mbox_file {
return if (!in_message_context("md_copy_orig_msg_to_work_dir_as_mbox_file"));
open(IN, "<INPUTMSG") or return 0;
unless (open(OUT, ">Work/INPUTMBOX")) {
open(IN, "<", "INPUTMSG") or return 0;
unless (open(OUT, ">", "Work/INPUTMBOX")) {
close(IN);
return 0;
}
Expand Down

0 comments on commit 3e0a7fb

Please sign in to comment.