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.
This commit is contained in:
Denis Kenzior 2019-04-29 14:16:17 -05:00
parent b126407632
commit 4a93c329b9
1 changed files with 1 additions and 1 deletions

View File

@ -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;