Package: libio-stringy-perl
Version: 2.110-1
Severity: grave
File: /usr/share/perl5/IO/AtomicFile.pm
Tags: patch

Upstream accepted the patch but did not make a new release yet.

I found a grave bug in IO::AtomicFile

I attached the script I tried.

I ran it and then I filled the disk space and ran it again but this time
I just got an empty file :(

Close exit code should be checked!

Patch attached.

Attachment: io_atomic_test.pl
Description: Perl program

--- IO/AtomicFile.pm
+++ IO/AtomicFile.pm
@@ -86,10 +86,13 @@
 sub close {
     my ($self, $die) = @_;
     unless ($self->_closed(1)) {             ### sentinel...
-        $self->SUPER::close();    
-        rename(${*$self}{'io_atomicfile_temp'},
-              ${*$self}{'io_atomicfile_path'}) 
-            or ($die ? die "close atomic file: $!\n" : return undef); 
+       if ($self->SUPER::close()) {
+               rename(${*$self}{'io_atomicfile_temp'},
+                      ${*$self}{'io_atomicfile_path'}) 
+                   or ($die ? die "close (rename) atomic file: $!\n" : return 
undef); 
+       } else {
+               $die ? die "close atomic file: $!\n" : return undef;
+       }
     }
     1;
 }

Reply via email to