Skip to content

Commit

Permalink
fix cx_err not checked
Browse files Browse the repository at this point in the history
  • Loading branch information
cedelavergne-ledger committed Dec 16, 2024
1 parent 2754e08 commit af456f7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src_features/provideDynamicNetwork/network_dynamic.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ static uint16_t parse_icon_buffer(void) {
uint8_t digest[CX_SHA256_SIZE];
const uint8_t *data = g_network_icon[g_current_slot].bitmap;
const uint16_t field_len = g_icon_payload.received_size;
cx_err_t error = CX_INTERNAL_ERROR;

// Check the icon header
sw = check_icon_header(data, field_len, &img_len);
Expand All @@ -298,7 +299,7 @@ static uint16_t parse_icon_buffer(void) {
CHECK_FIELD_OVERFLOW("NETWORK_ICON", g_network_icon[g_current_slot].bitmap);

// Check icon hash
cx_sha256_hash(data, field_len, digest);
CX_CHECK(cx_sha256_hash(data, field_len, digest));
if (memcmp(digest, g_network_icon[g_current_slot].hash, CX_SHA256_SIZE) != 0) {
PRINTF("NETWORK_ICON hash mismatch!\n");
return APDU_RESPONSE_INVALID_DATA;
Expand All @@ -313,7 +314,9 @@ static uint16_t parse_icon_buffer(void) {
DYNAMIC_NETWORK_INFO[g_current_slot].icon.isFile = true;
COPY_FIELD(DYNAMIC_NETWORK_INFO[g_current_slot].icon.bitmap);
print_icon_info();
return APDU_RESPONSE_OK;
error = APDU_RESPONSE_OK;
end:
return error;
}

/**
Expand Down

0 comments on commit af456f7

Please sign in to comment.