From 3eee8df6964fdca0d22967a5c8d65f934e935f34 Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Thu, 11 Aug 2016 20:24:54 +0530 Subject: swrap: Delay addition of child socket_info_fd into socket_info list In swrap_accept() we used to add new child socket_info_fd[child_fi] into newly created child socket_info struture[child_si] without considering the fact that we may return early in case of errors from subsequent calls to libc_getsockname() and sockaddr_convert_from_un() during which we free child_fi and child_si and return. So it is better to delay the addition of child_fi into child_si->fds until child_si is completely initialized. Signed-off-by: Anoop C S Reviewed-by: Michael Adam Reviewed-by: Andreas Schneider --- src/socket_wrapper.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index b11e4a9..00518c1 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -2682,8 +2682,6 @@ static int swrap_accept(int s, child_fi->fd = fd; - SWRAP_DLIST_ADD(child_si->fds, child_fi); - child_si->family = parent_si->family; child_si->type = parent_si->type; child_si->protocol = parent_si->protocol; @@ -2736,6 +2734,7 @@ static int swrap_accept(int s, }; memcpy(&child_si->myname.sa.ss, &in_my_addr.sa.ss, in_my_addr.sa_socklen); + SWRAP_DLIST_ADD(child_si->fds, child_fi); SWRAP_DLIST_ADD(sockets, child_si); if (addr != NULL) { -- cgit