mirror of
https://github.com/apache/nuttx-apps.git
synced 2025-10-19 19:44:35 +08:00
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:
@@ -119,7 +119,7 @@ int nsh_script(FAR struct nsh_vtbl_s *vtbl, FAR const FAR char *cmd,
|
||||
|
||||
/* 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 (log)
|
||||
|
Reference in New Issue
Block a user