From 10cd87175d78b733e4df147804e2173cd1932357 Mon Sep 17 00:00:00 2001 From: achazal Date: Tue, 2 Jun 2026 19:04:11 +0200 Subject: [PATCH] Fix buffer over-read in MADCardHolderInfoDecode --- client/src/mifare/mad.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/client/src/mifare/mad.c b/client/src/mifare/mad.c index 27eb6f4d3..de8f82be0 100644 --- a/client/src/mifare/mad.c +++ b/client/src/mifare/mad.c @@ -289,12 +289,14 @@ int MADCardHolderInfoDecode(uint8_t *data, size_t datalen, bool verbose) { uint8_t len = data[idx] & 0x3f; uint8_t type = data[idx] >> 6; idx++; - if (len > 0) { - PrintAndLogEx(INFO, "%14s " _GREEN_("%.*s"), holder_info_type[type], len, &data[idx]); - idx += len; - } else { + if (len == 0) + break; + if (idx + len > datalen) { + PrintAndLogEx(WARNING, "Card holder info truncated (need %u bytes, %zu available)", len, datalen - idx); break; } + PrintAndLogEx(INFO, "%14s " _GREEN_("%.*s"), holder_info_type[type], len, &data[idx]); + idx += len; } return PM3_SUCCESS; }