From: Oleg Moiseenko <807634+merlokk@users.noreply.github.com> Date: Sat, 17 Nov 2018 17:04:25 +0000 (+0200) Subject: fix get length in tlv (#714) X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/commitdiff_plain/14290308542a40adb5df5542ff035c3f3e5c5462 fix get length in tlv (#714) --- diff --git a/client/emv/tlv.c b/client/emv/tlv.c index 540c33e4..35bdb5d4 100644 --- a/client/emv/tlv.c +++ b/client/emv/tlv.c @@ -92,16 +92,15 @@ static size_t tlv_parse_len(const unsigned char **buf, size_t *len) return l; size_t ll = l &~ TLV_LEN_LONG; - if (*len < ll) + if (ll > 5) return TLV_LEN_INVALID; - /* FIXME */ - if (ll != 1) - return TLV_LEN_INVALID; - - l = **buf; - --*len; - ++*buf; + l = 0; + for (int i = 1; i <= ll; i++) { + l = (l << 8) + **buf; + --*len; + ++*buf; + } return l; }