Subject: | eval tests for DNS::RR::SIG fail when using a die handler |
Dear developers,
I use Net-DNS-0.48 using Perl 5.8, but I have seen the same behaviour as I describe here in Perl 5.005 and Perl 5.6.
When using a handler to catch die's (setting $SIG{'__DIE__'} to some subroutine reference) eval does not work as expected; instead of continuing the program when the evalled expression causes an exception the die-handler is called, resulting in the script to die. Net::DNS uses this construct at two places to check for DNS::RR::SIG; when this check fails and there is a custom die handler installed the script dies.
This can easily be solved by localising $SIG{'__DIE__'}. Lines 44-46 of Net/DNS.pm currently read:
BEGIN {
$DNSSEC = eval { require Net::DNS::RR::SIG; 1 } ? 1 : 0;
}
To solve this bug this could be changed to:
BEGIN {
$DNSSEC = eval {
local $SIG{'__DIE__'} = 'DEFAULT';
require Net::DNS::RR::SIG; 1
} ? 1 : 0;
}
Similarly, line 82 of Net/DNS/RR.pm which currently reads:
eval { require Net::DNS::RR::SIG; };
could be changed to:
eval {
local $SIG{'__DIE__'} = 'DEFAULT';
require Net::DNS::RR::SIG;
};
(But, in this last case, you might rather want to just check the $Net::DNS::DNSSEC variable you set earlier?)
Kind regards,
Sebastiaan Hoogeveen