Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions src_features/generic_tx_parser/gtp_param_datetime.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,25 @@ bool format_param_datetime(const s_param_datetime *param, const char *name) {
s_parsed_value_collection collec = {0};
char *buf = strings.tmp.tmp;
size_t buf_size = sizeof(strings.tmp.tmp);
uint8_t time_buf[sizeof(uint32_t)] = {0};
uint8_t time_buf[sizeof(time_t)] = {0};
time_t timestamp;
uint256_t block_height;

if ((ret = value_get(&param->value, &collec))) {
for (int i = 0; i < collec.size; ++i) {
if (param->type == DT_UNIX) {
buf_shrink_expand(collec.value[i].ptr,
collec.value[i].length,
time_buf,
sizeof(time_buf));
timestamp = read_u32_be(time_buf, 0);
if (!(ret = time_format_to_utc(&timestamp, buf, buf_size))) {
break;
if ((collec.value[i].length >= param->value.type_size) &&
ismaxint((uint8_t *) collec.value[i].ptr, collec.value[i].length)) {
snprintf(buf, buf_size, "Unlimited");
} else {
buf_shrink_expand(collec.value[i].ptr,
collec.value[i].length,
time_buf,
sizeof(time_buf));
timestamp = read_u64_be(time_buf, 0);
if (!(ret = time_format_to_utc(&timestamp, buf, buf_size))) {
break;
}
}
} else if (param->type == DT_BLOCKHEIGHT) {
convertUint256BE(collec.value[i].ptr, collec.value[i].length, &block_height);
Expand Down
12 changes: 9 additions & 3 deletions src_features/signMessageEIP712/ui_logic.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,11 +547,17 @@ static bool ui_712_format_trusted_name(const uint8_t *data, uint8_t length) {
*
* @param[in] data the data that needs formatting
* @param[in] length its length
* @param[in] field_ptr pointer to the new struct field
* @return whether it was successful or not
*/
static bool ui_712_format_datetime(const uint8_t *data, uint8_t length) {
time_t timestamp = u64_from_BE(data, length);
static bool ui_712_format_datetime(const uint8_t *data, uint8_t length, const void *field_ptr) {
time_t timestamp;

if ((length >= get_struct_field_typesize(field_ptr)) && ismaxint((uint8_t *) data, length)) {
snprintf(strings.tmp.tmp, sizeof(strings.tmp.tmp), "Unlimited");
return true;
}
timestamp = u64_from_BE(data, length);
return time_format_to_utc(&timestamp, strings.tmp.tmp, sizeof(strings.tmp.tmp));
}

Expand Down Expand Up @@ -629,7 +635,7 @@ bool ui_712_feed_to_display(const void *field_ptr,
}

if (ui_ctx->field_flags & UI_712_DATETIME) {
if (!ui_712_format_datetime(data, length)) {
if (!ui_712_format_datetime(data, length, field_ptr)) {
return false;
}
}
Expand Down
Loading