applied patch by ddick

This commit is contained in:
git@daemon.de
2015-03-24 11:22:54 +01:00
parent 766b8496c1
commit dc5038d15b
3 changed files with 16 additions and 8 deletions

View File

@@ -1,4 +1,6 @@
NEXT: 1.19:
applied patch by David Dick, which adds some more precautions
of i/o error handling and flushing.
1.17: 1.17:
added license to META added license to META

2
README
View File

@@ -52,5 +52,5 @@ AUTHOR
VERSION VERSION
1.17 1.19

View File

@@ -11,6 +11,8 @@ package Crypt::PWSafe3;
use strict; use strict;
use Config;
use Carp::Heavy; use Carp::Heavy;
use Carp; use Carp;
@@ -28,7 +30,7 @@ use Data::Dumper;
use Exporter (); use Exporter ();
use vars qw(@ISA @EXPORT); use vars qw(@ISA @EXPORT);
$Crypt::PWSafe3::VERSION = '1.18'; $Crypt::PWSafe3::VERSION = '1.19';
use Crypt::PWSafe3::Field; use Crypt::PWSafe3::Field;
use Crypt::PWSafe3::HeaderField; use Crypt::PWSafe3::HeaderField;
@@ -211,7 +213,8 @@ sub read {
# read and decrypt an existing vault file # read and decrypt an existing vault file
my($this) = @_; my($this) = @_;
my $fd = FileHandle->new($this->file, 'r'); my $file = $this->file();
my $fd = FileHandle->new($file, 'r') or croak "Could not open $file for reading: $!";
$fd->binmode(); $fd->binmode();
$this->{fd} = $fd; $this->{fd} = $fd;
@@ -301,7 +304,7 @@ sub read {
croak "File integrity check failed, invalid HMAC"; croak "File integrity check failed, invalid HMAC";
} }
$this->{fd}->close(); $this->{fd}->close() or croak "Could not close $file: $!";
} }
sub untaint { sub untaint {
@@ -416,7 +419,10 @@ sub save {
$this->hmac( $this->{hmacer}->digest() ); $this->hmac( $this->{hmacer}->digest() );
$this->writebytes($this->hmac); $this->writebytes($this->hmac);
$this->{fd}->close(); if ($Config{d_fsync}) {
$this->{fd}->sync() or croak "Could not fsync: $!";
}
$this->{fd}->close() or croak "Could not close tmpfile: $!";
# now try to read it in again to check if it # now try to read it in again to check if it
# is valid what we created # is valid what we created
@@ -429,7 +435,7 @@ sub save {
} }
else { else {
# well, seems to be ok :) # well, seems to be ok :)
move($tmpfile, $file); move($tmpfile, $file) or croak "Could not move $tmpfile to $file: $!";
} }
} }
@@ -973,7 +979,7 @@ License 2.0, see: L<http://www.perlfoundation.org/artistic_license_2_0>
=head1 VERSION =head1 VERSION
Crypt::PWSafe3 Version 1.17. Crypt::PWSafe3 Version 1.19.
=cut =cut