lnpeer: decode_short_ids: check length of short ids
- if `encoded_short_ids` does not decode into a whole number of `short_channel_id`:
- MAY send a `warning`.
- MAY close the connection.
0cf21511a7/07-routing-gossip.md (L674)
# Conflicts:
# electrum/lnpeer.py
This commit is contained in:
@@ -787,7 +787,9 @@ class Peer(Logger, EventListener):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def decode_short_ids(encoded):
|
def decode_short_ids(encoded):
|
||||||
if encoded[0] != 0:
|
if len(encoded) < 1 or (len(encoded) - 1) % 8 != 0:
|
||||||
|
raise Exception(f'decode_short_ids: invalid size: {len(encoded)=}')
|
||||||
|
elif encoded[0] != 0:
|
||||||
raise Exception(f'decode_short_ids: unexpected first byte: {encoded[0]}')
|
raise Exception(f'decode_short_ids: unexpected first byte: {encoded[0]}')
|
||||||
decoded = encoded[1:]
|
decoded = encoded[1:]
|
||||||
ids = [decoded[i:i+8] for i in range(0, len(decoded), 8)]
|
ids = [decoded[i:i+8] for i in range(0, len(decoded), 8)]
|
||||||
|
|||||||
Reference in New Issue
Block a user