stop userfile decode/thaw crashes

This commit is contained in:
Dirk Koopman 2019-12-20 14:38:15 +00:00
parent 448838ede7
commit fa7bdf4c84
3 changed files with 13 additions and 3 deletions

View File

@ -1,3 +1,5 @@
21Sep19=======================================================================
1. Harden userfile decode / thaw to stop crashes from corrupt records
10Sep19=======================================================================
1. Improve DXSql database filtering to exclude most via <locator> type
reports.

View File

@ -247,7 +247,7 @@ sub get
# search for it
unless ($dbm->get($call, $data)) {
$ref = decode($data);
$ref = eval{decode($data)};
if ($ref) {
if (!UNIVERSAL::isa($ref, 'DXUser')) {
dbg("DXUser::get: got strange answer from decode of $call". ref $ref. " ignoring");
@ -255,7 +255,7 @@ sub get
}
# we have a reference and it *is* a DXUser
} else {
dbg("DXUser::get: no reference returned from decode of $call $!");
dbg("DXUser::get: no reference returned from decode of $call $! $@");
return undef;
}
$lru->put($call, $ref);

View File

@ -115,9 +115,17 @@ sub get
my $r = $dbm->get($key, $value);
return undef if $r;
return thaw($value);
my $v;
eval { $v = thaw($value) };
if ($@) {
LogDbg("Error thawing DXQSL key '$key' (now deleted): $@");
eval {$dbm->del($key)};
return undef;
}
return $v;
}
sub put
{
return unless $dbm;