Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
gruve-p committed Dec 4, 2022
2 parents 94c9b29 + d7cd3e1 commit d1d2d45
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions contrib/pyln-proto/pyln/proto/wire.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,21 @@ def read_message(self):
length, = struct.unpack("!H", length)
self.rn += 1

mc = self.connection.recv(length + 16)
if len(mc) < length + 16:
raise ValueError(
"Short read reading the message: {} != {}".format(
length + 16, len(lc)
# Large messages may be split into multiple packets:
mc = b''
toread = length + 16
while len(mc) < length + 16:
d = self.connection.recv(toread)
if len(d) == 0:
# Not making progress anymore
raise ValueError(
"Short read reading the message: {} != {}".format(
length + 16, len(mc)
)
)
)
mc += d
toread -= len(d)

m = decryptWithAD(self.rk, self.nonce(self.rn), b'', mc)
self.rn += 1
assert(self.rn % 2 == 0)
Expand Down

0 comments on commit d1d2d45

Please sign in to comment.