apps/nshlib: nsh_getdirpath(), use snprint instead of sprintf to avoid possibility of buffer overrun. Noted by Chung Hwan Kim.

This commit is contained in:
Gregory Nutt 2016-10-11 17:35:31 -06:00
parent 909a4ec2ce
commit 9b951b4dd8

View File

@ -114,11 +114,11 @@ static char *nsh_getdirpath(FAR struct nsh_vtbl_s *vtbl,
if (strcmp(path, "/") == 0)
{
sprintf(vtbl->iobuffer, "/%s", file);
snprintf(vtbl->iobuffer, IOBUFFERSIZE, "/%s", file);
}
else
{
sprintf(vtbl->iobuffer, "%s/%s", path, file);
snprintf(vtbl->iobuffer, IOBUFFERSIZE, "%s/%s", path, file);
}
vtbl->iobuffer[PATH_MAX] = '\0';