[PATCH] openbsc[master]: gprs subscr: fix: intended strcmp(), but is strcpy()

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Fri Jan 13 02:41:13 UTC 2017


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

gprs subscr: fix: intended strcmp(), but is strcpy()

The code checked 'if (strcpy(..) != 0)' which is always true and thus always
copied twice -- luckily we want to copy anyway and so this is not an actual
functional failure.

We could correct to strcmp, but instead of iterating to compare, we might as
well copy right away.

Change-Id: I0ea035bd478f7022ed65e9e84d8aaf5e423309b7
---
M openbsc/src/gprs/gprs_subscriber.c
1 file changed, 3 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/90/1590/1

diff --git a/openbsc/src/gprs/gprs_subscriber.c b/openbsc/src/gprs/gprs_subscriber.c
index 23dbdd4..29e21ce 100644
--- a/openbsc/src/gprs/gprs_subscriber.c
+++ b/openbsc/src/gprs/gprs_subscriber.c
@@ -778,11 +778,9 @@
 		subscr->flags &= ~GPRS_SUBSCRIBER_ENABLE_PURGE;
 	}
 
-	if (strcpy(subscr->equipment.imei, mmctx->imei) != 0) {
-		strncpy(subscr->equipment.imei, mmctx->imei,
-			sizeof(subscr->equipment.imei)-1);
-		subscr->equipment.imei[sizeof(subscr->equipment.imei)-1] = 0;
-	}
+	strncpy(subscr->equipment.imei, mmctx->imei,
+		sizeof(subscr->equipment.imei)-1);
+	subscr->equipment.imei[sizeof(subscr->equipment.imei)-1] = 0;
 
 	if (subscr->lac != mmctx->ra.lac)
 		subscr->lac = mmctx->ra.lac;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0ea035bd478f7022ed65e9e84d8aaf5e423309b7
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>


More information about the gerrit-log mailing list