[PATCH] osmo-bsc[master]: mgcp: do not fail silently on snprintf()

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
Tue Nov 28 17:17:39 UTC 2017


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

mgcp: do not fail silently on snprintf()

The snprintf() that is used to compose the fsm name on an assignment
request may cause a silent failure. The buffer is large enough to
take the string under all circumstances. If snprintf() fails, this
would mean we have some other serious problem.

use OSMO_ASSERT in case the snprintf() fails, so the failure
gets noticed.

Change-Id: I3c36df8cfd0880c524244048a993cd136be41f56
---
M src/osmo-bsc/osmo_bsc_mgcp.c
1 file changed, 1 insertion(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/73/5073/1

diff --git a/src/osmo-bsc/osmo_bsc_mgcp.c b/src/osmo-bsc/osmo_bsc_mgcp.c
index be6c7de..81a4093 100644
--- a/src/osmo-bsc/osmo_bsc_mgcp.c
+++ b/src/osmo-bsc/osmo_bsc_mgcp.c
@@ -1015,8 +1015,7 @@
 	OSMO_ASSERT(mgcp);
 	OSMO_ASSERT(conn);
 
-	if(snprintf(name, sizeof(name), "MGW_%i", conn->conn_id) >= sizeof(name))
-		return NULL;
+	OSMO_ASSERT(snprintf(name, sizeof(name), "MGW_%i", conn->conn_id) < sizeof(name));
 
 	/* Register the fsm description (if not already done) */
 	if (fsm_registered == false) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3c36df8cfd0880c524244048a993cd136be41f56
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>



More information about the gerrit-log mailing list