[MERGED] openbsc[master]: libmsc/db: avoid subscr->name without terminating NULL char

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
Sat Nov 26 16:08:38 UTC 2016


Harald Welte has submitted this change and it was merged.

Change subject: libmsc/db: avoid subscr->name without terminating NULL char
......................................................................


libmsc/db: avoid subscr->name without terminating NULL char

Change-Id: Ic8944ac4c5e940c9d835c52f1701461f274238db
Fixes: Coverity CID 57621
---
M openbsc/src/libmsc/db.c
1 file changed, 3 insertions(+), 1 deletion(-)

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



diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c
index 68eba3e..5cccb32 100644
--- a/openbsc/src/libmsc/db.c
+++ b/openbsc/src/libmsc/db.c
@@ -831,8 +831,10 @@
 		subscr->tmsi = tmsi_from_string(string);
 
 	string = dbi_result_get_string(result, "name");
-	if (string)
+	if (string) {
 		strncpy(subscr->name, string, GSM_NAME_LENGTH);
+		subscr->name[sizeof(subscr->name)-1] = '\0';
+	}
 
 	string = dbi_result_get_string(result, "extension");
 	if (string)

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic8944ac4c5e940c9d835c52f1701461f274238db
Gerrit-PatchSet: 2
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list