The read() function doesn't add the '\0' character
to the end of string. So, this patch adds the '\0' char
on the last point of string if there is no error.
Change-Id: I1b3bf879b9c38f19edad8279d036c68655fae83b
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
ret = read(fd, buf, PATH_MAX);
close(fd);
- if (ret < 0)
+ if ((ret >= 0) && (ret <= PATH_MAX)) {
+ buf[ret] = '\0';
+ } else {
+ errno = EIO;
return -1;
+ }
filename = strrchr(buf, '/');
if (filename == NULL)