Skip to content

Commit 9530d02

Browse files
authored
Merge branch 'LedgerHQ:develop' into 7702-phase1
2 parents adc2401 + 415ad29 commit 9530d02

File tree

4 files changed

+32
-14
lines changed

4 files changed

+32
-14
lines changed

src_features/generic_tx_parser/gtp_param_datetime.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,25 @@ bool format_param_datetime(const s_param_datetime *param, const char *name) {
6969
s_parsed_value_collection collec = {0};
7070
char *buf = strings.tmp.tmp;
7171
size_t buf_size = sizeof(strings.tmp.tmp);
72-
uint8_t time_buf[sizeof(uint32_t)] = {0};
72+
uint8_t time_buf[sizeof(time_t)] = {0};
7373
time_t timestamp;
7474
uint256_t block_height;
7575

7676
if ((ret = value_get(&param->value, &collec))) {
7777
for (int i = 0; i < collec.size; ++i) {
7878
if (param->type == DT_UNIX) {
79-
buf_shrink_expand(collec.value[i].ptr,
80-
collec.value[i].length,
81-
time_buf,
82-
sizeof(time_buf));
83-
timestamp = read_u32_be(time_buf, 0);
84-
if (!(ret = time_format_to_utc(&timestamp, buf, buf_size))) {
85-
break;
79+
if ((collec.value[i].length >= param->value.type_size) &&
80+
ismaxint((uint8_t *) collec.value[i].ptr, collec.value[i].length)) {
81+
snprintf(buf, buf_size, "Unlimited");
82+
} else {
83+
buf_shrink_expand(collec.value[i].ptr,
84+
collec.value[i].length,
85+
time_buf,
86+
sizeof(time_buf));
87+
timestamp = read_u64_be(time_buf, 0);
88+
if (!(ret = time_format_to_utc(&timestamp, buf, buf_size))) {
89+
break;
90+
}
8691
}
8792
} else if (param->type == DT_BLOCKHEIGHT) {
8893
convertUint256BE(collec.value[i].ptr, collec.value[i].length, &block_height);

src_features/signMessageEIP712/ui_logic.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,11 +547,17 @@ static bool ui_712_format_trusted_name(const uint8_t *data, uint8_t length) {
547547
*
548548
* @param[in] data the data that needs formatting
549549
* @param[in] length its length
550+
* @param[in] field_ptr pointer to the new struct field
550551
* @return whether it was successful or not
551552
*/
552-
static bool ui_712_format_datetime(const uint8_t *data, uint8_t length) {
553-
time_t timestamp = u64_from_BE(data, length);
553+
static bool ui_712_format_datetime(const uint8_t *data, uint8_t length, const void *field_ptr) {
554+
time_t timestamp;
554555

556+
if ((length >= get_struct_field_typesize(field_ptr)) && ismaxint((uint8_t *) data, length)) {
557+
snprintf(strings.tmp.tmp, sizeof(strings.tmp.tmp), "Unlimited");
558+
return true;
559+
}
560+
timestamp = u64_from_BE(data, length);
555561
return time_format_to_utc(&timestamp, strings.tmp.tmp, sizeof(strings.tmp.tmp));
556562
}
557563

@@ -629,7 +635,7 @@ bool ui_712_feed_to_display(const void *field_ptr,
629635
}
630636

631637
if (ui_ctx->field_flags & UI_712_DATETIME) {
632-
if (!ui_712_format_datetime(data, length)) {
638+
if (!ui_712_format_datetime(data, length, field_ptr)) {
633639
return false;
634640
}
635641
}

tests/ragger/test_clone.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,11 @@ def test_clone_thundercore(firmware: Firmware,
3636
"value": Web3.to_wei(VALUE, "ether"),
3737
"chainId": 108
3838
}
39-
common(firmware, backend, navigator, scenario_navigator, default_screenshot_path, tx_params, test_name, BIP32_PATH)
39+
common(firmware,
40+
backend,
41+
navigator,
42+
scenario_navigator,
43+
default_screenshot_path,
44+
tx_params,
45+
test_name=test_name,
46+
path=BIP32_PATH)

tests/ragger/test_tx_simulation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def test_tx_simulation_sign(firmware: Firmware,
181181
scenario_navigator,
182182
default_screenshot_path,
183183
tx_params,
184-
test_name + f"_{config}",
184+
test_name=test_name + f"_{config}",
185185
with_simu=config not in ("benign", "issue"))
186186

187187

@@ -216,7 +216,7 @@ def test_tx_simulation_no_simu(firmware: Firmware,
216216
scenario_navigator,
217217
default_screenshot_path,
218218
tx_params,
219-
test_name,
219+
test_name=test_name,
220220
with_simu=False)
221221

222222

0 commit comments

Comments
 (0)