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
changes/88/3188/1
Neels Hofmeyr 6 years ago committed by Harald Welte
parent 3d07aef800
commit 04db87a89f
  1. 8
      openbsc/src/gprs/gprs_subscriber.c

@ -778,11 +778,9 @@ struct gsm_subscriber *gprs_subscr_get_or_create_by_mmctx(struct sgsn_mm_ctx *mm
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;

Loading…
Cancel
Save