mirror of
https://github.com/status-im/miniupnp.git
synced 2025-01-31 00:26:48 +00:00
fix encoding of length > 128
This commit is contained in:
parent
6ce08c5871
commit
f8b45ab854
@ -8,12 +8,10 @@ def codelength(s):
|
||||
l = len(s)
|
||||
if l == 0:
|
||||
return b'\x00'
|
||||
encodedlen = b''
|
||||
while l > 0:
|
||||
c = l & 0x7F
|
||||
encodedlen = (l & 0x7F).to_bytes(1, 'little')
|
||||
while l > 0x7F:
|
||||
l = l >> 7
|
||||
if l > 0:
|
||||
c = c + 128
|
||||
c = (l & 0x7F) | 0x80
|
||||
encodedlen = c.to_bytes(1, 'little') + encodedlen
|
||||
return encodedlen + s
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user