lmkd: Fix a potential buffer overflow
Prevent that the statement that writes '\0' past the read data can write past the end of the buffer. Bug: 213617178 Test: Compile-tested only. Change-Id: I6922c343a6bcb52dce0b5cf54f09b2850e9dfde2 Signed-off-by: Bart Van Assche <bvanassche@google.com>
This commit is contained in:
parent
545067957c
commit
5ebc4e8f51
2
lmkd.cpp
2
lmkd.cpp
|
|
@ -835,7 +835,7 @@ static void poll_kernel(int poll_fd) {
|
|||
|
||||
while (1) {
|
||||
char rd_buf[256];
|
||||
int bytes_read = TEMP_FAILURE_RETRY(pread(poll_fd, (void*)rd_buf, sizeof(rd_buf), 0));
|
||||
int bytes_read = TEMP_FAILURE_RETRY(pread(poll_fd, (void*)rd_buf, sizeof(rd_buf) - 1, 0));
|
||||
if (bytes_read <= 0) break;
|
||||
rd_buf[bytes_read] = '\0';
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue