lib: posix: Fix Out-of-bound write to char array
memcpy copies upto (rc-1)th index but the write of NULL character to the string is at (rc+1)th index skipping (rc)th index. The fix addresses this as well. CID: 186491 Fixes Issue #8280 Signed-off-by: Subramanian Meenakshi Sundaram <subbu147@gmail.com>
This commit is contained in:
parent
ff6dbc599c
commit
5193b5576f
1 changed files with 1 additions and 1 deletions
|
@ -297,7 +297,7 @@ struct dirent *readdir(DIR *dirp)
|
|||
memcpy(pdirent.d_name, fdirent.name, rc);
|
||||
|
||||
/* Make sure the name is NULL terminated */
|
||||
pdirent.d_name[rc + 1] = '\0';
|
||||
pdirent.d_name[rc] = '\0';
|
||||
return &pdirent;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue