[PATCH] 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/.

dexter gerrit-no-reply at lists.osmocom.org
Mon Jan 22 14:40:07 UTC 2018


Review at  https://gerrit.osmocom.org/5984

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(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/84/5984/1

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: newchange
Gerrit-Change-Id: I7f3562a344b58f6298d2068314be1626a96e1b1d
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>



More information about the gerrit-log mailing list