Skip to content

Commit df7a2ed

Browse files
authored
fix(legacy): fix OK-20918 & OK-20920 (#437)
1 parent c4ca34a commit df7a2ed

File tree

5 files changed

+12
-4
lines changed

5 files changed

+12
-4
lines changed

legacy/firmware/filecoin/parser.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ __Z_INLINE parser_error_t parser_printBigIntFixedPointTotal(
9595
bignum256 total = {0}, val = {0}, gas = {0}, limit = {0};
9696
uint8_t val_bytes[32] = {0};
9797
uint8_t gas_bytes[32] = {0};
98-
memcpy(val_bytes + (32 - value->len + 1), value->buffer + 1, value->len - 1);
98+
if (value->len > 0) {
99+
memcpy(val_bytes + (32 - value->len + 1), value->buffer + 1,
100+
value->len - 1);
101+
}
99102
memcpy(gas_bytes + (32 - gasfeecap->len + 1), gasfeecap->buffer + 1,
100103
gasfeecap->len - 1);
101104

legacy/firmware/language.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,7 @@ const char *languages[][2] = {
11761176
// u2f.c u2f.c
11771177
{"in this application.", ""},
11781178
// layout2.c
1179-
{"including fee:", "交易费:"},
1179+
{"including fee:", "包含交易费:"},
11801180
// fsm_msg_common.h
11811181
{"increase and retrieve", ""},
11821182
// fsm_msg_common.h

legacy/firmware/polkadot/parser.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ parser_error_t polkadot_parser_getItem(const parser_context_t *ctx,
169169
pageIdx, pageCount);
170170
if (err != parser_ok) return err;
171171
number_inplace_trimming(outVal, 0);
172+
const size_t len = strlen(outVal);
173+
if (outVal[len - 1] == '.') outVal[len - 1] = '\0';
172174
return err;
173175
}
174176

legacy/firmware/polkadot/parser_impl_common.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ parser_error_t _toStringCompactInt(const compactInt_t *c, uint8_t decimalPlaces,
211211

212212
if (trimTrailingZeros) {
213213
number_inplace_trimming(bufferUI, 0);
214+
const size_t len = strlen(bufferUI);
215+
if (bufferUI[len - 1] == '.') bufferUI[len - 1] = '\0';
214216
}
215217

216218
if (z_str3join(bufferUI, sizeof(bufferUI), prefix, postfix) != zxerr_ok) {

legacy/firmware/polkadot/substrate/substrate_types.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,9 @@ parser_error_t _substrate_toStringBalance(const pd_Balance_t* v, char* outValue,
340340
return parser_unexpected_value;
341341
}
342342

343-
number_inplace_trimming(bufferUI, 1);
344-
number_inplace_trimming(bufferUI, 1);
343+
number_inplace_trimming(bufferUI, 0);
344+
const size_t len = strlen(bufferUI);
345+
if (bufferUI[len - 1] == '.') bufferUI[len - 1] = '\0';
345346
if (z_str3join(bufferUI, sizeof(bufferUI), "", __polkadot_ticker) !=
346347
zxerr_ok) {
347348
return parser_print_not_supported;

0 commit comments

Comments
 (0)