diff options
author | Nick Kralevich <nnk@google.com> | 2012-07-17 10:32:07 -0700 |
---|---|---|
committer | Nick Kralevich <nnk@google.com> | 2012-07-17 10:34:15 -0700 |
commit | 9acc2486787ee83b436b2999cd27f7b1ffb9fd69 (patch) | |
tree | 4b1f2d5ce418a4517eafe79ea56ca69bd08ffec4 | |
parent | 2e2afadd535ad3a92246fd3482f39a9174d814e9 (diff) | |
download | external_libnfc-nxp-9acc2486787ee83b436b2999cd27f7b1ffb9fd69.zip external_libnfc-nxp-9acc2486787ee83b436b2999cd27f7b1ffb9fd69.tar.gz external_libnfc-nxp-9acc2486787ee83b436b2999cd27f7b1ffb9fd69.tar.bz2 |
phHal4Nfc_ADD: fix memcpy overlap
Don't call memcpy when src==dest. It's undefined.
When memcpy overlap detection is enabled, this causes the NFC
process to crash and burn.
Bug: 6826770
Change-Id: I199af98e453953de288964f47248cb59af4deecb
-rw-r--r-- | src/phHal4Nfc_ADD.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/phHal4Nfc_ADD.c b/src/phHal4Nfc_ADD.c index 0a3303c..727b7c4 100644 --- a/src/phHal4Nfc_ADD.c +++ b/src/phHal4Nfc_ADD.c @@ -671,11 +671,14 @@ void phHal4Nfc_TargetDiscoveryComplete( if(phHal_eNfcIP1_Target == Hal4Ctxt->rem_dev_list[Count-1]->RemDevType) { - (void)memcpy( - (void *)Hal4Ctxt->rem_dev_list[0], - (void *)Hal4Ctxt->rem_dev_list[Count-1], - sizeof(phHal_sRemoteDevInformation_t) - ); + if (Count != 1) + { + (void)memcpy( + (void *)Hal4Ctxt->rem_dev_list[0], + (void *)Hal4Ctxt->rem_dev_list[Count-1], + sizeof(phHal_sRemoteDevInformation_t) + ); + } NfcIpDeviceCount = 1; break; } |