From 4a93c329b9139af380da49ef373e7ad72834d210 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Mon, 29 Apr 2019 14:16:17 -0500 Subject: [PATCH] log: Fix potential buffer overflow We pass in the maximum size of the buffer to the read system call. On the astronomically unlikely chance that we indeed read the full buffer full of data, the subsequent assignment will overflow it. Fix this by passing sizeof(buf) - 1 to the read system call instead. --- src/log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/log.c b/src/log.c index 8047084c..b3bcbc2c 100644 --- a/src/log.c +++ b/src/log.c @@ -185,7 +185,7 @@ static void print_backtrace(unsigned int offset) if (written < 0) break; - len = read(infd[0], buf, sizeof(buf)); + len = read(infd[0], buf, sizeof(buf) - 1); if (len < 0) break;