Skip to content

Commit

Permalink
Merge pull request #566 from LedgerHQ/cev/fix-amountToString
Browse files Browse the repository at this point in the history
Fix potential oob writes
  • Loading branch information
cedelavergne-ledger authored Apr 12, 2024
2 parents a27c984 + 5b905fe commit c6a909a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src_common/common_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,11 @@ bool amountToString(const uint8_t *amount,
uint8_t amount_len = strnlen(tmp_buffer, sizeof(tmp_buffer));
uint8_t ticker_len = strnlen(ticker, MAX_TICKER_LEN);

memcpy(out_buffer, ticker, MIN(out_buffer_size, ticker_len));
if (ticker_len > 0) {
if (out_buffer_size <= ticker_len + 1) {
return false;
}
memcpy(out_buffer, ticker, ticker_len);
out_buffer[ticker_len++] = ' ';
}

Expand Down

0 comments on commit c6a909a

Please sign in to comment.