From: Sebastian Date: Tue, 30 Jun 2015 20:27:28 +0000 (+0200) Subject: FTNMAIL: don't die on invalid filenames X-Git-Url: http://sraa.de/git/?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=fido.git FTNMAIL: don't die on invalid filenames --- diff --git a/modules/FTNMAIL.pm b/modules/FTNMAIL.pm index ac3d0a1..40e2a80 100644 --- a/modules/FTNMAIL.pm +++ b/modules/FTNMAIL.pm @@ -190,11 +190,21 @@ sub unpack_packet($) my $file = shift; my $buf, my @mails; - die("No filename!") unless($file); - open(PKT, '<', $file) or die("Can't open $file!\n"); + if(!$file) { + LOG::warn("No filename!"); + return; + } + + if(!(open(PKT, '<', $file))) { + LOG::warn("Can't open $file!"); + return; + } binmode(PKT); - die("Short packet!") if(read(PKT, $buf, 0x3a) != 0x3a); + if(read(PKT, $buf, 0x3a) != 0x3a) { + LOG::warn("Short packet!"); + return; + } # parse packet header my ($onode, $dnode, $year, $month, $day, $hour, $minute, $second, @@ -203,7 +213,10 @@ sub unpack_packet($) $ozone, $dzone, $opoint, $dpoint, $data) = unpack( "v v v v v v v v v v v v C C Z8 v v v n C C v v v v v a4", $buf); - die("Unsupported packet type $type!") unless($type == 2); + if($type != 2) { + LOG::warn("Unsupported packet type $type!"); + return; + } my %packet; if(($cw == $cwcopy) && ($cw != 0) && ($cw & 0x0001)) { @@ -227,17 +240,24 @@ sub unpack_packet($) # read packed messages while(1) { - die("Short packet!") if(read(PKT, $buf, 2) != 2); + if(read(PKT, $buf, 2) != 2) { + LOG::warn("Short packet!"); + return; + } my $type = unpack("v", $buf); if($type == 0) { close(PKT); return(@mails); } elsif($type != 2) { - die("Unsupported message type $type!"); + LOG::warn("Unsupported message type $type!"); + return; } - die("Short packet!") if(read(PKT, $buf, 0x20) != 0x20); + if(read(PKT, $buf, 0x20) != 0x20) { + LOG::warn("Short packet!"); + return; + } # parse message header my ($tname, $fname, $subj, $text);