From cb2ecc3156b2106b84d436dd6fcb696efd76ccce Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Fri, 3 Jun 2016 16:09:53 +0100 Subject: [PATCH] Don't clobber the last null terminator when reading /proc/cmdline. Right now, if /proc/cmdline is larger than the buffer size (1024) then the read will overwrite all of the null terminators and the ensuing strstr calls will continue past the end of the buffer. Bug: 29115540 Change-Id: I2da2f28edabd7926d40dbcea52ebaf7165c44e04 --- rild/rild.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rild/rild.c b/rild/rild.c index b32afe4..a3090cd 100644 --- a/rild/rild.c +++ b/rild/rild.c @@ -217,7 +217,7 @@ int main(int argc, char **argv) { } do { - len = read(fd,buffer,sizeof(buffer)); } + len = read(fd,buffer,sizeof(buffer) - 1); } while (len == -1 && errno == EINTR); if (len < 0) { -- 2.11.0