Skip Menu |

This queue is for tickets about the IO-stringy CPAN distribution.

Report information
The Basics
Id: 25425
Status: new
Priority: 0/
Queue: IO-stringy

People
Owner: Nobody in particular
Requestors: edpeur [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: (no value)
Fixed in: (no value)



Subject: IO::AtomicFile critical bug on file close
I found a critical problem 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! I already let the author know of this bug three months ago. And it is even fixed in the Debian GNU/Linux distribution. I am posting it here so nobody forgets this bug.
Subject: io_atomic_test.pl
#!/usr/bin/perl -w use strict; use IO::AtomicFile; my $filename = "/tmp/atomicfile_test.txt"; my $ATOMICFH = IO::AtomicFile->open($filename, "w") or die "Error opening: " . $filename . ' ' . $!; print $ATOMICFH "Test" or die "Error writing to: " . $filename . ' ' . $!; $ATOMICFH->close or die "Error closing: " . $filename . ' ' . $!;
Subject: io_atomicfile_close_fix_severity_critical.diff
--- 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; }