diff options
author | bptato <nincsnevem662@gmail.com> | 2023-09-28 17:57:55 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-09-28 17:57:55 +0200 |
commit | ef8124638b6b056a4721918b47fc00a349ab0da1 (patch) | |
tree | 4f46e23f1d6e13eefef3c2f32ce57fed194fe4d6 /src/io | |
parent | 7724082d68c452064025fa30c1c0c0127f936621 (diff) | |
download | chawan-ef8124638b6b056a4721918b47fc00a349ab0da1.tar.gz |
posixstream: fix buffer overflow
Diffstat (limited to 'src/io')
-rw-r--r-- | src/io/posixstream.nim | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/io/posixstream.nim b/src/io/posixstream.nim index e24facde..970a50e6 100644 --- a/src/io/posixstream.nim +++ b/src/io/posixstream.nim @@ -38,8 +38,9 @@ proc psReadData(s: Stream, buffer: pointer, len: int): int = assert len != 0 let s = cast[PosixStream](s) let wasend = s.isend + let buffer = cast[ptr UncheckedArray[uint8]](buffer) while result < len: - let n = read(s.fd, cast[pointer](cast[int](buffer) + result), len) + let n = read(s.fd, addr buffer[result], len - result) if n < 0: if result == 0: result = n |