Subject: | Missing error handling on missing dictionary entry |
Currently, parsing of Packets dies of an unknown $type comes in a packet.
This patch changes the bevaviour to print a warning on STDERR and
continue parsing.
This enables better debugging as well as gracefull handling of
unneeded/unknown chunks/types in request packets.
For example, the line
ATTRIBUTE NAS-Identifier 32 string
is missing in the dictionary for PAM/OpenSSH. Parsing is not actually
required, authentication seems to work just fine anyway with the patch.
Subject: | RADIUS_failsafe.patch |
diff -rupN RADIUS-1.0_old/RADIUS/Packet.pm RADIUS-1.0/RADIUS/Packet.pm
--- RADIUS-1.0_old/RADIUS/Packet.pm 2012-03-18 19:37:52.083326134 +0100
+++ RADIUS-1.0/RADIUS/Packet.pm 2012-03-18 19:40:54.467770068 +0100
@@ -160,6 +160,12 @@ sub unpack {
while (length($attrdat)) {
my $length = unpack "x C", $attrdat;
my ($type, $value) = unpack "C x a${\($length-2)}", $attrdat;
+ if(!defined($dict->attr_numtype($type))) {
+ print STDERR "Unknown type $type! Skipping this one - might have dire consequences)!\n";
+ print STDERR " Please add type $type to your dictionary!\n";
+ substr($attrdat, 0, $length) = "";
+ next;
+ }
my $val = &{$unpacker{$dict->attr_numtype($type)}}($value, $type);
$self->set_attr($dict->attr_name($type), $val);
substr($attrdat, 0, $length) = "";