Fix race condition when card is removed during read and libfreefare returns list of just NULL pointer

This commit is contained in:
Ondrej Mikle 2021-12-28 22:38:05 +01:00
parent 5e4d16a857
commit 079db13938

View file

@ -165,6 +165,10 @@ std::string NFCDevice::readDesfireNDEF() throw(NFCError)
if (!tags) { if (!tags) {
throw NFCError("No tags detected"); throw NFCError("No tags detected");
} }
// freefare_get_tags() returns a NULL-terminated list of MifareTag
if (!*tags) {
throw NFCError("Empty array tag, bailing out");
}
MifareTag& tag = *tags; //only first one is used MifareTag& tag = *tags; //only first one is used
if (DESFIRE != freefare_get_tag_type (tag)) { if (DESFIRE != freefare_get_tag_type (tag)) {