diff options
-rwxr-xr-x | dmarcts-report-parser.pl | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/dmarcts-report-parser.pl b/dmarcts-report-parser.pl index c33f655..6c4264a 100755 --- a/dmarcts-report-parser.pl +++ b/dmarcts-report-parser.pl @@ -410,7 +410,7 @@ if ($reports_source == TS_IMAP) { unlink($f); } $counts++; - } elsif (open FILE, $f) { + } elsif (open(FILE, "<", $f)) { $filecontent = join("", <FILE>); close FILE; @@ -643,7 +643,7 @@ sub getXMLFromMessage { open(XML, "<:gzip", $location) or $unzip = "ungzip"; } else { - open(XML,"unzip -p " . $location . " |") + open(XML, "-|", "unzip", "-p", $location) or $unzip = "unzip"; # Will never happen. # Sadly unzip -p never failes, but we can check if the @@ -651,7 +651,6 @@ sub getXMLFromMessage { # not open/failed. if (eof XML) { $unzip = "unzip"; - close XML; } } @@ -666,6 +665,7 @@ sub getXMLFromMessage { } else { warn "$scriptname: Subject: $subj\n:"; warn "$scriptname: Failed to $unzip ZIP file (temp. location: <$location>)! \n"; + close XML; } } else { warn "$scriptname: Subject: $subj\n:"; @@ -683,10 +683,8 @@ sub getXMLFromZip { my $filename = $_[0]; my $mtype = mimetype($filename); - if (open FILE, $filename) { - if ($debug) { - print "Filename: $filename, MimeType: $mtype\n"; - } + if ($debug) { + print "Filename: $filename, MimeType: $mtype\n"; } my $isgzip = 0; @@ -716,7 +714,7 @@ sub getXMLFromZip { open(XML, "<:gzip", $filename) or $unzip = "ungzip"; } else { - open(XML,"unzip -p " . $filename . " |") + open(XML, "-|", "unzip", "-p", $filename) or $unzip = "unzip"; # Will never happen. # Sadly unzip -p never failes, but we can check if the @@ -724,7 +722,6 @@ sub getXMLFromZip { # not open/failed. if (eof XML) { $unzip = "unzip"; - close XML; } } @@ -737,6 +734,7 @@ sub getXMLFromZip { close XML; } else { warn "$scriptname: Failed to $unzip ZIP file (<$filename>)! \n"; + close XML; } } else { warn "$scriptname: Could not find an <$filename>! \n"; |