add guard for size_t underflow

This commit is contained in:
iceman1001
2026-03-24 14:21:09 +07:00
parent 0d63e53a77
commit c62b9e0480
+9
View File
@@ -600,6 +600,15 @@ void *mifare_cryto_postprocess_data(desfiretag_t tag, void *data, size_t *nbytes
if ((communication_settings & MAC_VERIFY) == MAC_VERIFY) {
if (*nbytes < key_macing_length(key)) {
*nbytes = -1;
res = NULL;
#ifdef WITH_DEBUG
Dbprintf("No room for MAC!");
#endif
break;
}
*nbytes -= key_macing_length(key);
if (*nbytes == 0) {