Change in osmo-bsc[master]: unlink socket path correctly in rf_create_socket()

Stefan Sperling gerrit-no-reply at
Mon Nov 19 12:04:58 UTC 2018

Stefan Sperling has submitted this change and it was merged. ( )

Change subject: unlink socket path correctly in rf_create_socket()

unlink socket path correctly in rf_create_socket()

In commit 65c62e50335b500ac9e4658530ca5a1b4f5328d8 a call
to unlink() was erroneously moved up. Since then unlink()
has been called with an uninitialized path variable. The
problem went unnoticed because the return value of unlink()
was never checked.

Ensure that unlink() is called with an initialized argument and
verify success of the unlink() operation if the socket exists.

Related: CID#188836
Change-Id: Ia0c873da305cbb47aef0562f61ec21057363f294
Fixes: 65c62e50335b500ac9e4658530ca5a1b4f5328d8
M src/osmo-bsc/bsc_rf_ctrl.c
1 file changed, 5 insertions(+), 1 deletion(-)

  Jenkins Builder: Verified
  Pau Espin Pedrol: Looks good to me, approved

diff --git a/src/osmo-bsc/bsc_rf_ctrl.c b/src/osmo-bsc/bsc_rf_ctrl.c
index ac87fb9..791abf6 100644
--- a/src/osmo-bsc/bsc_rf_ctrl.c
+++ b/src/osmo-bsc/bsc_rf_ctrl.c
@@ -450,12 +450,16 @@
 	local.sun_family = AF_UNIX;
-	unlink(local.sun_path);
 	if (osmo_strlcpy(local.sun_path, path, sizeof(local.sun_path)) >= sizeof(local.sun_path)) {
 		LOGP(DLINP, LOGL_ERROR, "Socket path exceeds maximum length of %zd bytes: %s\n",
 		     sizeof(local.sun_path), path);
 		return -1;
+	if (unlink(local.sun_path) < 0 && errno != ENOENT) {
+		LOGP(DLINP, LOGL_ERROR, "Could not unlink socket path %s: %d/%s\n",
+		     path, errno, strerror(errno));
+		return -1;
+	}
 	/* we use the same magic that X11 uses in Xtranssock.c for
 	 * calculating the proper length of the sockaddr */

To view, visit
To unsubscribe, or for help writing mail filters, visit

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia0c873da305cbb47aef0562f61ec21057363f294
Gerrit-Change-Number: 11782
Gerrit-PatchSet: 5
Gerrit-Owner: Stefan Sperling <ssperling at>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <pespin at>
Gerrit-Reviewer: Stefan Sperling <ssperling at>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the gerrit-log mailing list