my $headers = $self->_read_headers($fh);
- $self->_read_body($fh, $key, "$magic$headers");
+ eval {
+ $self->_read_body($fh, $key, "$magic$headers");
+ };
+ if (my $err = $@) {
+ throw "Failed to load KDBX file: $err",
+ error => $err,
+ compression_error => $IO::Uncompress::Gunzip::GunzipError,
+ crypt_error => $File::KDBX::IO::Crypt::ERROR,
+ hash_error => $File::KDBX::IO::HashBLock::ERROR,
+ hmac_error => $File::KDBX::IO::HmacBLock::ERROR;
+ }
}
sub _read_headers {
}
$self->_read_inner_body($fh);
+ close($fh);
if (my $header_hash = $kdbx->meta->{header_hash}) {
my $got_header_hash = digest_data('SHA256', $header_data);
return $self;
}
-sub DESTROY { !in_global_destruction and $_[0]->unlock }
+sub DESTROY { local ($., $@, $!, $^E, $?); !in_global_destruction and $_[0]->unlock }
=method clear