lib: posix: fix out-of-bound write

Ensure that write is in buffer limits

Coverity-CID: 186491

Signed-off-by: Paras Jain <parasjain2000@gmail.com>
This commit is contained in:
Paras Jain 2018-06-07 11:12:49 -07:00 committed by Maureen Helm
commit bf1e0198a7

View file

@ -293,7 +293,7 @@ struct dirent *readdir(DIR *dirp)
} }
rc = strlen(fdirent.name); rc = strlen(fdirent.name);
rc = (rc <= PATH_MAX) ? rc : PATH_MAX; rc = (rc < PATH_MAX) ? rc : (PATH_MAX - 1);
memcpy(pdirent.d_name, fdirent.name, rc); memcpy(pdirent.d_name, fdirent.name, rc);
/* Make sure the name is NULL terminated */ /* Make sure the name is NULL terminated */