From d6145d76e7d572743bce8eb75d84b09e00da1e47 Mon Sep 17 00:00:00 2001 From: Ray Lee Date: Tue, 24 Aug 2021 10:43:32 +0800 Subject: [PATCH] fix buffer overflow --- client/src/cmdhfmfdes.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index 2685d7f0c..d4a8b4944 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -689,9 +689,10 @@ static int CmdHF14ADesInfo(const char *Cmd) { iso14a_card_select_t card; res = SelectCard14443A_4(true, false, &card); if (res == PM3_SUCCESS) { - static const char STANDALONE_DESFIRE[] = { 0x75, 0x77, 0x81, 0x02}; - static const char JCOP_DESFIRE[] = { 0x75, 0xf7, 0xb1, 0x02 }; - static const char JCOP3_DESFIRE[] = { 0x78, 0x77, 0x71, 0x02 }; + // convert to str by adding \0 to the end. so we can use strlen() to calc length + static const char STANDALONE_DESFIRE[] = { 0x75, 0x77, 0x81, 0x02, '\0' }; + static const char JCOP_DESFIRE[] = { 0x75, 0xf7, 0xb1, 0x02, '\0' }; + static const char JCOP3_DESFIRE[] = { 0x78, 0x77, 0x71, 0x02, '\0' }; if (card.sak == 0x20) {