You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/09/27 04:20:31 UTC

[incubator-nuttx-apps] 01/03: netutils/dhcpc: Set close-on-exec by default to avoid udp_conn leak

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit cbcfe6be2804ba5a70c381689844058e198ed3f3
Author: chao an <an...@xiaomi.com>
AuthorDate: Tue Sep 27 02:56:21 2022 +0800

    netutils/dhcpc: Set close-on-exec by default to avoid udp_conn leak
    
    Signed-off-by: chao an <an...@xiaomi.com>
---
 netutils/dhcpc/dhcpc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/netutils/dhcpc/dhcpc.c b/netutils/dhcpc/dhcpc.c
index efac5f701..3ec6c4af6 100644
--- a/netutils/dhcpc/dhcpc.c
+++ b/netutils/dhcpc/dhcpc.c
@@ -542,7 +542,7 @@ FAR void *dhcpc_open(FAR const char *interface, FAR const void *macaddr,
 
       /* Create a UDP socket */
 
-      pdhcpc->sockfd = socket(PF_INET, SOCK_DGRAM, 0);
+      pdhcpc->sockfd = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
       if (pdhcpc->sockfd < 0)
         {
           ninfo("socket handle %d\n", pdhcpc->sockfd);