[Pdbg] [PATCH 06/14] gdbserver: fix read buffer overflow
Nicholas Piggin
npiggin at gmail.com
Mon Mar 14 15:17:27 AEDT 2022
buffer gets NUL terminated so read must return max of size-1.
Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
---
src/pdbgproxy.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c
index 906ed2f..78b1236 100644
--- a/src/pdbgproxy.c
+++ b/src/pdbgproxy.c
@@ -388,7 +388,7 @@ static int read_from_client(int fd)
char buffer[BUFFER_SIZE + 1];
int nbytes;
- nbytes = read(fd, buffer, sizeof(buffer));
+ nbytes = read(fd, buffer, sizeof(buffer) - 1);
if (nbytes < 0) {
perror(__FUNCTION__);
return -1;
--
2.23.0
More information about the Pdbg
mailing list