Skip to content

Commit df3b4b5

Browse files
mtoddJohn Wedoff
authored andcommitted
Extract getbyte_nonblock, use with read_ber_length
1 parent aec21d9 commit df3b4b5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/net/ber/ber_parser.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def parse_ber_object(syntax, id, data)
136136
# invalid BER length case. Because the "lengthlength" value was not used
137137
# inside of #read_ber, we no longer return it.
138138
def read_ber_length
139-
n = getbyte
139+
n = getbyte_nonblock
140140

141141
if n <= 0x7f
142142
n
@@ -185,6 +185,11 @@ def read_ber(syntax = nil)
185185

186186
# Internal: Returns the BER message ID or nil.
187187
def read_ber_id
188+
getbyte_nonblock
189+
end
190+
191+
# Internal: Replaces `getbyte` with nonblocking implementation.
192+
def getbyte_nonblock
188193
begin
189194
read_nonblock(1).ord
190195
rescue IO::WaitReadable

0 commit comments

Comments
 (0)