mirror of https://github.com/status-im/nim-eth.git
Adapt to latest snappy; Avoid decompression bombs
This commit is contained in:
parent
5eff071c8e
commit
73c1bb817c
|
@ -258,7 +258,7 @@ proc invokeThunk*(peer: Peer, msgId: int, msgData: var Rlp): Future[void] =
|
||||||
template compressMsg(peer: Peer, data: seq[byte]): seq[byte] =
|
template compressMsg(peer: Peer, data: seq[byte]): seq[byte] =
|
||||||
when useSnappy:
|
when useSnappy:
|
||||||
if peer.snappyEnabled:
|
if peer.snappyEnabled:
|
||||||
snappy.compress(data)
|
snappy.encode(data)
|
||||||
else: data
|
else: data
|
||||||
else:
|
else:
|
||||||
data
|
data
|
||||||
|
@ -422,7 +422,7 @@ proc recvMsg*(peer: Peer): Future[tuple[msgId: int, msgData: Rlp]] {.async.} =
|
||||||
|
|
||||||
when useSnappy:
|
when useSnappy:
|
||||||
if peer.snappyEnabled:
|
if peer.snappyEnabled:
|
||||||
decryptedBytes = snappy.uncompress(decryptedBytes)
|
decryptedBytes = snappy.decode(decryptedBytes, maxMsgSize)
|
||||||
if decryptedBytes.len == 0:
|
if decryptedBytes.len == 0:
|
||||||
await peer.disconnectAndRaise(BreachOfProtocol,
|
await peer.disconnectAndRaise(BreachOfProtocol,
|
||||||
"Snappy uncompress encountered malformed data")
|
"Snappy uncompress encountered malformed data")
|
||||||
|
|
Loading…
Reference in New Issue