Skip to content

Commit 81cb59a

Browse files
Merge pull request #676 from LedgerHQ/fix/apa/dynamic_networks_tlv_parser_oob
Fix potential out-of-bounds read by up to 2 bytes during TLV parsing
2 parents 1a373e6 + 51bc8b2 commit 81cb59a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src_features/provideDynamicNetwork/network_dynamic.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,10 @@ static uint16_t parse_tlv(const uint8_t *data, uint8_t length) {
493493
cx_sha256_init(&sig_ctx.hash_ctx);
494494
// handle TLV payload
495495
while (offset != length) {
496+
if ((offset + 2) > length) {
497+
sw = APDU_RESPONSE_INVALID_DATA;
498+
break;
499+
}
496500
tag_start_off = offset;
497501
field_tag = data[offset++];
498502
field_len = data[offset++];

0 commit comments

Comments
 (0)