summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2016-11-25 23:59:43 +0100
committerHarald Welte <laforge@gnumonks.org>2016-11-26 17:10:30 +0100
commit3d7230b2a2bb5e49192ee316418b0e1572882555 (patch)
tree1f11dd9e569d26dd59c90be1352bc27da12c61fe
parent1bda28c70911d47f129227daf34f1c7e1a059744 (diff)
libmsc/db: Prevent subscr->extension without NULL termination
Change-Id: Ic1ae7b2d9dde8dab8f7795e5baa8918424f5f393 Fixes: Coverity CID 57622
-rw-r--r--openbsc/src/libmsc/db.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c
index 5cccb3280..c212fcd28 100644
--- a/openbsc/src/libmsc/db.c
+++ b/openbsc/src/libmsc/db.c
@@ -837,8 +837,10 @@ static void db_set_from_query(struct gsm_subscriber *subscr, dbi_conn result)
}
string = dbi_result_get_string(result, "extension");
- if (string)
+ if (string) {
strncpy(subscr->extension, string, GSM_EXTENSION_LENGTH);
+ subscr->extension[sizeof(subscr->extension)-1] = '\0';
+ }
subscr->lac = dbi_result_get_ulonglong(result, "lac");