From f8b45ab85489117a251a2bc95ae764489d222635 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Tue, 12 Jan 2021 01:01:47 +0100 Subject: [PATCH] fix encoding of length > 128 --- minissdpd/submit_to_minissdpd.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/minissdpd/submit_to_minissdpd.py b/minissdpd/submit_to_minissdpd.py index 2bcc239..6d441d6 100755 --- a/minissdpd/submit_to_minissdpd.py +++ b/minissdpd/submit_to_minissdpd.py @@ -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