Skip to content

Commit

Permalink
enable O_CLOEXEC explicitly to avoid fd leak
Browse files Browse the repository at this point in the history
Signed-off-by: wanggang26 <[email protected]>
  • Loading branch information
wanggang26 committed Sep 16, 2024
1 parent 872208f commit 5d34f35
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion drivers/misc/optee.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion libs/libc/netdb/lib_dnsbind.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion libs/libc/time/lib_localtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5d34f35

Please sign in to comment.