[MERGED] libosmocore[master]: socket: fix socket leak in osmo_sock_local_ip()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon Jan 22 15:00:21 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: socket: fix socket leak in osmo_sock_local_ip()
......................................................................


socket: fix socket leak in osmo_sock_local_ip()

The socket that is opend to probe the correct local ip-address is
not closed when the test is done.

- Close socket when it is not needed anymore

Change-Id: I7f3562a344b58f6298d2068314be1626a96e1b1d
---
M src/socket.c
1 file changed, 1 insertion(+), 0 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/socket.c b/src/socket.c
index 82ccfed..35cce64 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -827,6 +827,7 @@
 	memset(&local_addr, 0, sizeof(local_addr));
 	local_addr_len = sizeof(local_addr);
 	rc = getsockname(sfd, (struct sockaddr *)&local_addr, &local_addr_len);
+	close(sfd);
 	if (rc < 0)
 		return -EINVAL;
 	if (local_addr.sin_family == AF_INET)

-- 
To view, visit https://gerrit.osmocom.org/5984
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I7f3562a344b58f6298d2068314be1626a96e1b1d
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list