Skip to content

Commit 08f82eb

Browse files
committed
another u8 overflow, and sanity checks'
1 parent 87ad69a commit 08f82eb

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

armsrc/seos.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,8 +715,8 @@ void SimulateSeos(seos_emulate_req_t *msg) {
715715
uint8_t *request = work_buffer_a;
716716
decrypt_cryptogram(diver_encr_key, cryptogram, cryptogram_length, request, msg->encr_alg);
717717

718-
uint8_t tlv_base = 1 + offset;
719-
uint8_t tlv_idx = tlv_base;
718+
uint16_t tlv_base = 1 + offset;
719+
uint16_t tlv_idx = tlv_base;
720720

721721
if (is_put) {
722722
// TODO: Add write support
@@ -762,6 +762,12 @@ void SimulateSeos(seos_emulate_req_t *msg) {
762762
break;
763763
}
764764

765+
// Pre-flight: 2 (cryptogram tag+len) + reply_len + 4 (status) + 2 (CMAC tag+len) + recvd_cmac_length
766+
if (tlv_base + 2 + reply_len + 4 + 2 + recvd_cmac_length > DYNAMIC_RESPONSE_BUFFER_SIZE) {
767+
Dbprintf(_RED_("Get Data failed") ": Response too large for buffer.");
768+
break;
769+
}
770+
765771
// Only include a cryptogram for GET DATA
766772
dynamic_response_info.response[tlv_idx++] = 0x85; // Tag: cryptogram
767773
dynamic_response_info.response[tlv_idx++] = reply_len; // Length

0 commit comments

Comments
 (0)