about summary refs log tree commit diff stats
path: root/src/io
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-09-28 17:57:55 +0200
committerbptato <nincsnevem662@gmail.com>2023-09-28 17:57:55 +0200
commitef8124638b6b056a4721918b47fc00a349ab0da1 (patch)
tree4f46e23f1d6e13eefef3c2f32ce57fed194fe4d6 /src/io
parent7724082d68c452064025fa30c1c0c0127f936621 (diff)
downloadchawan-ef8124638b6b056a4721918b47fc00a349ab0da1.tar.gz
posixstream: fix buffer overflow
Diffstat (limited to 'src/io')
-rw-r--r--src/io/posixstream.nim3
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