Skip to content

Commit af677a5

Browse files
committed
Pad based on most significant bit in octet
Was just looking at most significant bit.
1 parent dc21554 commit af677a5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/net/ber/core_ext/fixnum.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ def to_ber_internal
4848
size -= 1
4949
end
5050

51-
# for positive integers, if most significant bit is set to one,
51+
# for positive integers, if most significant bit in an octet is set to one,
5252
# pad the result (otherwise it's decoded as a negative value)
5353
# See section 8.5 of ITU-T X.690:
5454
# http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf
55-
if self > 0 && (self & (0b10000000 << (size - 1))) > 0
55+
if self > 0 && (self & (0b10000000 << (size - 1) * 8)) > 0
5656
size += 1
5757
end
5858

0 commit comments

Comments
 (0)