From 96a68a1ddc4707742519e658a775c4d6cb5d4a30 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 19 Feb 2024 18:21:19 +0100 Subject: [PATCH] fuzzing seems to believe we would actually write more than 50 bytes of ATR... --- client/src/cmdsmartcard.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/src/cmdsmartcard.c b/client/src/cmdsmartcard.c index 217cb7d86..da81c8249 100644 --- a/client/src/cmdsmartcard.c +++ b/client/src/cmdsmartcard.c @@ -1172,8 +1172,8 @@ static int CmdSmartBruteforceSFI(const char *Cmd) { } static void atsToEmulatedAtr(uint8_t *ats, uint8_t *atr, int *atrLen) { - int historicalLen = 0; - int offset = 2; + uint8_t historicalLen = 0; + uint8_t offset = 2; if (ats[0] < 2) { historicalLen = 0; @@ -1202,7 +1202,7 @@ static void atsToEmulatedAtr(uint8_t *ats, uint8_t *atr, int *atrLen) { atr[3] = 0x01; uint8_t tck = atr[1] ^ atr[2] ^ atr[3]; - for (int i = 0; i < historicalLen; ++i) { + for (uint8_t i = 0; i < historicalLen; ++i) { atr[4 + i] = ats[offset + i]; tck = tck ^ ats[offset + i]; } @@ -1302,7 +1302,7 @@ static int CmdPCSC(const char *Cmd) { if (bytes_read > 0) { if (cmdbuf[1] == 0x01 && cmdbuf[2] == 0x04) { // vpcd GET ATR - uint8_t atr[50] = {0}; + uint8_t atr[256] = {0}; int atrLen = 0; switch (card_type) {