Permalink
Browse files

Get rid of unlink

$tftp->get deletes the destination file. If the destination is a symlink
this will delete the link and try to create a file. This is probably not
what the user wanted because it's probably a symlink for a reason. This
fix removes the unlink entirely because the following IO::File->new()
does not need it.
  • Loading branch information...
1 parent 91aa751 commit c0e85f80cc8e4665e1df4919651d183dbbf4ca84 @MaikHentscheAMD MaikHentscheAMD committed with Sep 16, 2010
Showing with 3 additions and 4 deletions.
  1. +3 −4 TFTP.pm
View
7 TFTP.pm
@@ -129,12 +129,11 @@ sub get {
my $file = $local;
unless(ref($local)) {
- my $retval = unlink($file);
- if ($retval < 1) {
- $self->{'error'} = "Can not unlink $file: $!";
+ $local = IO::File->new($file,O_WRONLY|O_TRUNC|O_CREAT);
+ unless ($local) {
+ $self->{'error'} = "Can not open $file: $!";
return undef;
}
- $local = IO::File->new($file,O_WRONLY|O_TRUNC|O_CREAT);
}
binmode $local if $self->{'Mode'} eq 'octet';

0 comments on commit c0e85f8

Please sign in to comment.