Fix big amounts (#199)

* Fix wrong display of amounts >= 2^87

* Add test to check that amounts >= 2^87 make the app throw

* Bump v1.9.7 and update changelog
This commit is contained in:
Jean P
2021-10-04 11:26:01 +02:00
committed by GitHub
parent fb7204fb6c
commit 408805f751
5 changed files with 29 additions and 11 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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';
}

View File

@@ -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);
}

View File

@@ -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(