mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 15:58:59 +08:00
enable O_CLOEXEC explicitly to avoid fd leak
Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
This commit is contained in:
@@ -569,7 +569,7 @@ static int optee_ioctl_cancel(FAR struct socket *psocket,
|
||||
static int
|
||||
optee_ioctl_shm_alloc(FAR struct tee_ioctl_shm_alloc_data *data)
|
||||
{
|
||||
int memfd = memfd_create(OPTEE_SERVER_PATH, O_CREAT);
|
||||
int memfd = memfd_create(OPTEE_SERVER_PATH, O_CREAT | O_CLOEXEC);
|
||||
|
||||
if (memfd < 0)
|
||||
{
|
||||
|
||||
@@ -69,7 +69,7 @@ int dns_bind(sa_family_t family)
|
||||
|
||||
/* Create a new socket */
|
||||
|
||||
sd = socket(family, SOCK_DGRAM, 0);
|
||||
sd = socket(family, SOCK_DGRAM | SOCK_CLOEXEC, 0);
|
||||
if (sd < 0)
|
||||
{
|
||||
ret = -get_errno();
|
||||
|
||||
@@ -685,7 +685,7 @@ static int tzload(FAR const char *name,
|
||||
goto oops;
|
||||
}
|
||||
|
||||
fid = _NX_OPEN(name, O_RDONLY);
|
||||
fid = _NX_OPEN(name, O_RDONLY | O_CLOEXEC);
|
||||
if (fid < 0)
|
||||
{
|
||||
goto oops;
|
||||
|
||||
Reference in New Issue
Block a user