diff --git a/CHANGELOG.md b/CHANGELOG.md index f9e6b82..fba9db8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [1.9.7](https://github.com/ledgerhq/app-ethereum/compare/1.9.6...1.9.7) - 2021-9-30 + +### Fixed + +- Fixed a bug where amounts displayed where wrong when the amount was huge (>=2^87) + ## [1.9.6](https://github.com/ledgerhq/app-ethereum/compare/1.9.5...1.9.6) - 2021-9-29 ### Fixed diff --git a/Makefile b/Makefile index 25f8b61..02e600a 100755 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ APP_LOAD_PARAMS += --path "1517992542'/1101353413'" APPVERSION_M=1 APPVERSION_N=9 -APPVERSION_P=6 +APPVERSION_P=7 APPVERSION=$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P) APP_LOAD_FLAGS= --appFlags 0x240 --dep Ethereum:$(APPVERSION) diff --git a/src/utils.c b/src/utils.c index 5048119..40575da 100644 --- a/src/utils.c +++ b/src/utils.c @@ -118,10 +118,8 @@ void amountToString(const uint8_t *amount, uint8_t out_buffer_size) { char tmp_buffer[100] = {0}; - bool success = uint256_to_decimal(amount, amount_size, tmp_buffer, sizeof(tmp_buffer)); - - if (!success) { - THROW(0x6504); + if (uint256_to_decimal(amount, amount_size, tmp_buffer, sizeof(tmp_buffer)) == false) { + THROW(EXCEPTION_OVERFLOW); } uint8_t amount_len = strnlen(tmp_buffer, sizeof(tmp_buffer)); @@ -129,11 +127,14 @@ void amountToString(const uint8_t *amount, memcpy(out_buffer, ticker, MIN(out_buffer_size, ticker_len)); - adjustDecimals(tmp_buffer, - amount_len, - out_buffer + ticker_len, - out_buffer_size - ticker_len - 1, - decimals); + if (adjustDecimals(tmp_buffer, + amount_len, + out_buffer + ticker_len, + out_buffer_size - ticker_len - 1, + decimals) == false) { + THROW(EXCEPTION_OVERFLOW); + } + out_buffer[out_buffer_size - 1] = '\0'; } diff --git a/src_features/signTx/logic_signTx.c b/src_features/signTx/logic_signTx.c index 7ebdb2f..ad0a1f6 100644 --- a/src_features/signTx/logic_signTx.c +++ b/src_features/signTx/logic_signTx.c @@ -440,7 +440,7 @@ void finalizeParsing(bool direct) { displayBuffer, sizeof(displayBuffer)); compareOrCopy(strings.common.fullAmount, - sizeof(strings.common.fullAddress), + sizeof(strings.common.fullAmount), displayBuffer, called_from_swap); } diff --git a/tests/src/send.test.js b/tests/src/send.test.js index b71ad53..cb82ef4 100644 --- a/tests/src/send.test.js +++ b/tests/src/send.test.js @@ -1,6 +1,7 @@ import "core-js/stable"; import "regenerator-runtime/runtime"; import { waitForAppScreen, zemu } from './test.fixture'; +import { TransportStatusError } from "@ledgerhq/errors"; test('[Nano S] Transfer Ether on Ethereum app', zemu("nanos", async (sim, eth) => { @@ -19,6 +20,16 @@ test('[Nano S] Transfer Ether on Ethereum app', zemu("nanos", async (sim, eth) = }); })); +test('[Nano S] Transfer amount >= 2^87 Eth on Ethereum app should fail', zemu("nanos", async (sim, eth) => { + + const tx = eth.signTransaction( + "44'/60'/1'/0/0", + 'f83f268e02cc9be5c53ea44bd43c289dcddc82520894dac17f958d2ee523a2206206994597c13d831ec7928db8b0861b8f7fe5df83cd553a829878000080018080', + ); + + await expect(tx).rejects.toEqual(new TransportStatusError(0x6807)); +})); + test('[Nano S] Transfer Ether on network 5234 on Ethereum app', zemu("nanos", async (sim, eth) => { const tx = eth.signTransaction(