From ddf58f2d6982c14f7112c73ec31ecbdb723e9836 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Fri, 20 Sep 2013 00:13:21 +0200 Subject: [PATCH] Changing conditions to avoid Coverity to complain in artificial situations CID 1090331 (#1 of 1): Out-of-bounds access (OVERRUN) 11. overrun-buffer-arg: Overrunning array "pnti->nai.abtUid" of 10 bytes by passing it to a function which accesses it at byte offset 11 using argument "pnti->nai.szUidLen" (which evaluates to 12). --- libnfc/chips/pn53x.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index 7f142f7..bb25dd8 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -503,7 +503,8 @@ pn53x_decode_target_data(const uint8_t *pbtRawData, size_t szRawData, pn53x_type if ((pnti->nai.szUidLen == 8) && (pbtUid[0] == 0x88)) { pnti->nai.szUidLen = 7; memcpy(pnti->nai.abtUid, pbtUid + 1, 7); - } else if ((pnti->nai.szUidLen == 12) && (pbtUid[0] == 0x88) && (pbtUid[4] == 0x88)) { +// } else if ((pnti->nai.szUidLen == 12) && (pbtUid[0] == 0x88) && (pbtUid[4] == 0x88)) { + } else if (pnti->nai.szUidLen > 10) { pnti->nai.szUidLen = 10; memcpy(pnti->nai.abtUid, pbtUid + 1, 3); memcpy(pnti->nai.abtUid + 3, pbtUid + 5, 3);