read() could write up to PATH_MAX chars to array
and return it as res, then we write to this array at res
position which is out of bound index.
exepath[res] = '\0';
sizeof(exepath) is equal to res, so it is out of bounds write.
Change-Id: I1c1a2f00998933e5ff7bc17409ea6a228b21475c
Signed-off-by: Ernest Borowski <e.borowski@samsung.com>
ssize_t res;
- if ((res = read(fd, exepath, len)) == -1) {
+ if ((res = read(fd, exepath, len - 1)) == -1) {
LOGE("read() cmdline error: %m\n");
close(fd);
return false;