Skip to content

Commit 1b8bce9

Browse files
author
blackhedd
committed
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.
1 parent 1decab1 commit 1b8bce9

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/net/ber.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,12 @@ def read_ber syntax=nil
106106
when :array
107107
seq = []
108108
sio = StringIO.new( newobj || "" )
109-
while e = sio.read_ber(syntax); seq << e; end
109+
# Interpret the subobject, but note how the loop
110+
# is built: nil ends the loop, but false (a valid
111+
# BER value) does not!
112+
while (e = sio.read_ber(syntax)) != nil
113+
seq << e
114+
end
110115
seq
111116
else
112117
raise BerError.new( "unsupported object type: class=#{tagclass}, encoding=#{encoding}, tag=#{tag}" )
@@ -224,11 +229,9 @@ def to_ber code = 4
224229

225230
#
226231
# to_ber_application_string
227-
# TODO. WARNING, IS THIS WRONG? Shouldn't app-specific string
228-
# have a prefix of 0x40?
229232
#
230233
def to_ber_application_string code
231-
to_ber( 0x80 + code )
234+
to_ber( 0x40 + code )
232235
end
233236

234237
#

0 commit comments

Comments
 (0)