From d9b531f50fa51c5fa35f079ea5dce2d3fac9373e Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sun, 22 Sep 2013 01:31:45 +0200 Subject: [PATCH] Verify return of nfc_device_set_property_bool() Problem reported by Coverity CID 1090319 (#1 of 1): Unchecked return value (CHECKED_RETURN) unchecked_value: No check of the return value of "nfc_device_set_property_bool(pnd, NP_EASY_FRAMING, nt.nti.nai.btSak & 0x20)". CID 1090320 (#1 of 1): Unchecked return value (CHECKED_RETURN) unchecked_value: No check of the return value of "nfc_device_set_property_bool(dev, NP_HANDLE_CRC, false)". CID 1090324 (#1 of 2): Unchecked return value (CHECKED_RETURN) unchecked_value: No check of the return value of "nfc_device_set_property_bool(pnd, NP_ACTIVATE_FIELD, true)". CID 1090325 (#1 of 1): Unchecked return value (CHECKED_RETURN) unchecked_value: No check of the return value of "nfc_device_set_property_bool(pnd, NP_AUTO_ISO14443_4, false)". --- examples/nfc-emulate-tag.c | 14 ++++++++++++-- utils/nfc-mfclassic.c | 10 ++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/examples/nfc-emulate-tag.c b/examples/nfc-emulate-tag.c index e233c96..3192095 100644 --- a/examples/nfc-emulate-tag.c +++ b/examples/nfc-emulate-tag.c @@ -166,7 +166,12 @@ nfc_target_emulate_tag(nfc_device *dev, nfc_target *pnt) } if (loop) { if (init_mfc_auth) { - nfc_device_set_property_bool(dev, NP_HANDLE_CRC, false); + if (nfc_device_set_property_bool(dev, NP_HANDLE_CRC, false) < 0) { + nfc_perror(pnd, "nfc_target_emulate_tag"); + nfc_close(pnd); + nfc_exit(context); + exit(EXIT_FAILURE); + } init_mfc_auth = false; } if ((szRx = nfc_target_receive_bytes(dev, abtRx, sizeof(abtRx), 0)) < 0) { @@ -276,7 +281,12 @@ main(int argc, char *argv[]) print_nfc_target(&nt, true); // Switch off NP_EASY_FRAMING if target is not ISO14443-4 - nfc_device_set_property_bool(pnd, NP_EASY_FRAMING, (nt.nti.nai.btSak & SAK_ISO14443_4_COMPLIANT)); + if (nfc_device_set_property_bool(pnd, NP_EASY_FRAMING, (nt.nti.nai.btSak & SAK_ISO14443_4_COMPLIANT)) < 0) { + nfc_perror(pnd, "nfc_target_emulate_tag"); + nfc_close(pnd); + nfc_exit(context); + exit(EXIT_FAILURE); + } printf("NFC device (configured as target) is now emulating the tag, please touch it with a second NFC device (initiator)\n"); if (!nfc_target_emulate_tag(pnd, &nt)) { nfc_perror(pnd, "nfc_target_emulate_tag"); diff --git a/utils/nfc-mfclassic.c b/utils/nfc-mfclassic.c index 90312de..f012d97 100644 --- a/utils/nfc-mfclassic.c +++ b/utils/nfc-mfclassic.c @@ -280,8 +280,14 @@ get_rats(void) res = nfc_initiator_transceive_bytes(pnd, abtRats, sizeof(abtRats), abtRx, sizeof(abtRx), 0); if (res > 0) { // ISO14443-4 card, turn RF field off/on to access ISO14443-3 again - nfc_device_set_property_bool(pnd, NP_ACTIVATE_FIELD, false); - nfc_device_set_property_bool(pnd, NP_ACTIVATE_FIELD, true); + if (nfc_device_set_property_bool(pnd, NP_ACTIVATE_FIELD, false) < 0) { + nfc_perror(pnd, "nfc_configure"); + return -1; + } + if (nfc_device_set_property_bool(pnd, NP_ACTIVATE_FIELD, true) < 0) { + nfc_perror(pnd, "nfc_configure"); + return -1; + } } // Reselect tag if (nfc_initiator_select_passive_target(pnd, nmMifare, NULL, 0, &nt) <= 0) {