nshlib: enable O_CLOEXEC explicit to avoid potential fd leak
leaking here means fork/vfork will duplicate fd without O_CLOEXEC flag to the child process. Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
This commit is contained in:
parent
f27e755ad7
commit
bae15dfd58
@ -119,7 +119,7 @@ int nsh_script(FAR struct nsh_vtbl_s *vtbl, FAR const FAR char *cmd,
|
|||||||
|
|
||||||
/* Open the file containing the script */
|
/* Open the file containing the script */
|
||||||
|
|
||||||
vtbl->np.np_fd = open(fullpath, O_RDOK);
|
vtbl->np.np_fd = open(fullpath, O_RDOK | O_CLOEXEC);
|
||||||
if (vtbl->np.np_fd < 0)
|
if (vtbl->np.np_fd < 0)
|
||||||
{
|
{
|
||||||
if (log)
|
if (log)
|
||||||
|
@ -598,7 +598,7 @@ static int cmd_rpmsg_once(FAR struct nsh_vtbl_s *vtbl,
|
|||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = open(path, 0);
|
fd = open(path, O_CLOEXEC);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
nsh_output(vtbl, g_fmtarginvalid, path);
|
nsh_output(vtbl, g_fmtarginvalid, path);
|
||||||
|
Loading…
Reference in New Issue
Block a user