Skip Menu |

This queue is for tickets about the Convert-BER CPAN distribution.

Report information
The Basics
Id: 18587
Status: resolved
Priority: 0/
Queue: Convert-BER

People
Owner: Nobody in particular
Requestors: martin.wiederkehr [...] intradoemea.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.3101
Fixed in: (no value)



Subject: Problem with indefinite BER-lengths
Hi. I've found a tiny problem in theConvert::BER module. Indefinite length of BER-strings are not handled 100% correct. Please find attached a Perl-script pointing out the problem. The problem shown in the script is, that the indefinite-length terminator 0x0000 is not cut off completely and I have a remaining 0x00 byte at the end of my data. The consequence is that the Decoder thinks that there are still some remaining bytes in the buffer to be decoded, but there should not be any left. Hope I submitted enough information to point out the problem. Best Regards. Martin.
Subject: test_convert_ber_indefinite_lengths.pl
#!/usr/bin/perl -w use strict; use Convert::BER; print <<EOT; Structure of the BER-string with indefinite length 30 12 80 08 02181060414710f2 a2 80 80008100 0000 EOT my ($string1, $string2, $ber, $retval); my $ber_indefinite = pack("H*", '3012800802181060414710f2a280800081000000'); my $ber_definite = pack("H*", '3010800802181060414710f2a20480008100'); print "========== definite length =============\n"; $ber = new Convert::BER($ber_definite); $ber->hexdump(); # This decoding works fine $retval = $ber->decode( SEQUENCE => [ [ STRING => 0x80 ] => \$string1, [ STRING => 0xA2 ] => \$string2, ], ); unless (defined($retval)) { print $ber->error(); } print "string1: <".unpack("H*",$string1).">\n" if (defined($string1)); print "string2: <".unpack("H*",$string2).">\n" if (defined($string2)); print "========== indefinite length =============\n"; $ber = new Convert::BER($ber_indefinite); $ber->hexdump(); # This decoding here struggles with the indefinite length of the 0xA2 tag. # The problem is that the outcome in $string2 contains one 00-byte at the # end which is part of the terminator. This means instead of 80008100 I # get 8000810000. $retval = $ber->decode( SEQUENCE => [ [ STRING => 0x80 ] => \$string1, [ STRING => 0xA2 ] => \$string2, ], ); unless (defined($retval)) { print $ber->error(); } print "string1: <".unpack("H*",$string1).">\n" if (defined($string1)); print "string2: <".unpack("H*",$string2).">\n" if (defined($string2));