[Pdbg] [PATCH v2 09/38] gdbserver: fix read buffer overflow
Nicholas Piggin
npiggin at gmail.com
Wed Mar 30 02:49:02 AEDT 2022
buffer gets NUL terminated so read must return max of size - 1.
Reviewed-by: Joel Stanley <joel at jms.id.au>
Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
---
src/pdbgproxy.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c
index 906ed2f..4c6327f 100644
--- a/src/pdbgproxy.c
+++ b/src/pdbgproxy.c
@@ -385,10 +385,10 @@ static void destroy_client(int dead_fd)
static int read_from_client(int fd)
{
- char buffer[BUFFER_SIZE + 1];
+ char buffer[BUFFER_SIZE];
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