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:
parent
909a4ec2ce
commit
9b951b4dd8
@ -114,11 +114,11 @@ static char *nsh_getdirpath(FAR struct nsh_vtbl_s *vtbl,
|
|||||||
|
|
||||||
if (strcmp(path, "/") == 0)
|
if (strcmp(path, "/") == 0)
|
||||||
{
|
{
|
||||||
sprintf(vtbl->iobuffer, "/%s", file);
|
snprintf(vtbl->iobuffer, IOBUFFERSIZE, "/%s", file);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf(vtbl->iobuffer, "%s/%s", path, file);
|
snprintf(vtbl->iobuffer, IOBUFFERSIZE, "%s/%s", path, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
vtbl->iobuffer[PATH_MAX] = '\0';
|
vtbl->iobuffer[PATH_MAX] = '\0';
|
||||||
|
Loading…
Reference in New Issue
Block a user