[PATCH] 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 13:44:36 UTC 2016


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

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


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/10/1310/1

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: newchange
Gerrit-Change-Id: Ic8944ac4c5e940c9d835c52f1701461f274238db
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>



More information about the gerrit-log mailing list