The 'len + 1' of argument of read() might access
the out of range of 'buf' string. This patch fixes
the overrun issue.
Change-Id: I68d0bd4404515f492a0dc2624aba2d7f51630118
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
if (fd == -1)
return -ENOENT;
- r = read(fd, buf, len + 1);
+ r = read(fd, buf, len);
close(fd);
if ((r < 0) || (r > len))
int sysfs_read_int(char *path, int *val)
{
- char buf[MAX_BUF_SIZE];
+ char buf[MAX_BUF_SIZE + 1];
int r;
if ((!path) || (!val))
int sysfs_write_int(char *path, int val)
{
- char buf[MAX_BUF_SIZE];
+ char buf[MAX_BUF_SIZE + 1];
int w;
if (!path)