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

Harald Welte gerrit-no-reply at lists.osmocom.org
Sun Jan 15 18:10:48 UTC 2017


Harald Welte has submitted this change and it was merged.

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


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

Approvals:
  Max: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



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: merged
Gerrit-Change-Id: I0ea035bd478f7022ed65e9e84d8aaf5e423309b7
Gerrit-PatchSet: 2
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>


More information about the gerrit-log mailing list