From a3d1b7c215d2a7f5c14c0e013a3dfcae8dfe150d Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 24 Feb 2017 18:04:29 -0500 Subject: [PATCH] LP#1667835: avoid edi_fetcher.pl crash upon fetching zero-length file This patch fixes an issue that could cause edi_fetcher.pl to crash if the EDI partner supplies a zero-length file for Net::FTP to download; such files are now skipped. Testing would entail setting up an FTP server that contains a zero-length file, then setting up an EDI remote account and using edi_fetcher.pl to try to retrieve the file. Signed-off-by: Galen Charlton Signed-off-by: Chris Sharp Signed-off-by: Jason Stephenson --- .../src/perlmods/lib/OpenILS/Utils/RemoteAccount.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Utils/RemoteAccount.pm b/Open-ILS/src/perlmods/lib/OpenILS/Utils/RemoteAccount.pm index 8c7682d171..b4a8f1ecf1 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Utils/RemoteAccount.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Utils/RemoteAccount.pm @@ -605,6 +605,7 @@ sub get_ftp { my $self = shift; my $filename; + my $remote_filename = $self->{get_args}->[0]; eval { $filename = $self->_ftp->get(@{$self->{get_args}}) }; if ($@ or not $filename) { $logger->error( @@ -614,6 +615,16 @@ sub get_ftp { ); return; } + if (!defined(${$filename->sref})) { + # the underlying scalar is still undef, so Net::FTP must have + # successfully retrieved an empty file... which we should skip + $logger->error( + $self->_error( + "get $remote_filename from", $self->remote_host, ": remote file is zero-length" + ) + ); + return; + } $self->local_file($filename); $logger->info( -- 2.43.2