From 5eefe7d14ca6c3e28abdda8e66ace458e5ee1a57 Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Sat, 31 Jul 2021 20:33:54 +0300 Subject: [PATCH] fix split block length bug --- client/src/mifare/desfirecore.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/src/mifare/desfirecore.c b/client/src/mifare/desfirecore.c index 443c623d5..5b32176b6 100644 --- a/client/src/mifare/desfirecore.c +++ b/client/src/mifare/desfirecore.c @@ -695,8 +695,13 @@ static void DesfireSplitBytesToBlock(uint8_t *blockdata, size_t *blockdatacount, size_t len = 0; for (int i = 0; i < *blockdatacount; i++) { size_t tlen = len + blockdata[i * blockdatasize]; - if (tlen > dstdatalen) + if (tlen > dstdatalen) { tlen = dstdatalen; + if (tlen >= len) + blockdata[i * blockdatasize] = tlen - len; + else + blockdata[i * blockdatasize] = 0; + } if (len == tlen) { *blockdatacount = i; break;