From 1b8bce9051dddef5494ed3abb18579d2bb1e283a Mon Sep 17 00:00:00 2001 From: blackhedd Date: Mon, 17 Apr 2006 00:32:24 +0000 Subject: [PATCH] Fixed two bugs: 1) We were incorrectly halting sequence-parses when the sequence contained a boolean FALSE value; 2) We were generating application strings with a tag class of 0x80 (context-specific) rather than 0x40. --- lib/net/ber.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/net/ber.rb b/lib/net/ber.rb index 21f4dcc..cf64bca 100644 --- a/lib/net/ber.rb +++ b/lib/net/ber.rb @@ -106,7 +106,12 @@ module Net when :array seq = [] sio = StringIO.new( newobj || "" ) - while e = sio.read_ber(syntax); seq << e; end + # Interpret the subobject, but note how the loop + # is built: nil ends the loop, but false (a valid + # BER value) does not! + while (e = sio.read_ber(syntax)) != nil + seq << e + end seq else raise BerError.new( "unsupported object type: class=#{tagclass}, encoding=#{encoding}, tag=#{tag}" ) @@ -224,11 +229,9 @@ class String # # to_ber_application_string - # TODO. WARNING, IS THIS WRONG? Shouldn't app-specific string - # have a prefix of 0x40? # def to_ber_application_string code - to_ber( 0x80 + code ) + to_ber( 0x40 + code ) end #