mirror of
https://github.com/codex-storage/nim-libp2p.git
synced 2025-01-12 12:04:08 +00:00
Improve connection.nim read error clarity when buffer overflow
This commit is contained in:
parent
120ba0d528
commit
f9cbdc252f
@ -122,8 +122,10 @@ proc readLp*(s: Connection): Future[seq[byte]] {.async, gcsafe.} =
|
|||||||
res = LP.getUVarint(buff.toOpenArray(0, i), length, size)
|
res = LP.getUVarint(buff.toOpenArray(0, i), length, size)
|
||||||
if res == VarintStatus.Success:
|
if res == VarintStatus.Success:
|
||||||
break
|
break
|
||||||
if res != VarintStatus.Success or size > DefaultReadSize:
|
if res != VarintStatus.Success:
|
||||||
raise newInvalidVarintException()
|
raise newInvalidVarintException()
|
||||||
|
if size > DefaultReadSize:
|
||||||
|
raise newLPStreamLimitError()
|
||||||
buff.setLen(size)
|
buff.setLen(size)
|
||||||
if size > 0.uint:
|
if size > 0.uint:
|
||||||
trace "reading exact bytes from stream", size = size
|
trace "reading exact bytes from stream", size = size
|
||||||
|
Loading…
x
Reference in New Issue
Block a user