Skip to content

Commit ec0b08c

Browse files
committed
fixes
1 parent fa8e960 commit ec0b08c

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

app/ui/view_nbgl.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,12 +472,12 @@ static void config_useCaseReview(nbgl_operationType_t type) {
472472
if (app_mode_blindsign_required()) {
473473
nbgl_useCaseReviewBlindSigning(type, &pairList, &C_icon_stax_64,
474474
(intro_message == NULL ? "Review transaction" : intro_message),
475-
(intro_submessage == NULL ? NULL : intro_submessage),
475+
intro_submessage,
476476
"Accept risk and sign transaction ?", NULL, reviewTransactionChoice);
477477
} else {
478478
nbgl_useCaseReview(
479479
type, &pairList, &C_icon_stax_64, (intro_message == NULL ? "Review transaction" : intro_message),
480-
(intro_submessage == NULL ? NULL : intro_submessage),
480+
intro_submessage,
481481
(approval_label_buf[0] != '\0' ? approval_label_buf : APPROVE_LABEL_NBGL), reviewTransactionChoice);
482482
}
483483
}
@@ -587,8 +587,14 @@ void view_review_show_with_intent_impl(unsigned int requireReply, const char *in
587587
const char *review_text = (review_type == REVIEW_MSG) ? "Review message" : "Review transaction";
588588
int ret = snprintf(intro_msg_buf, sizeof(intro_msg_buf), "%s to %s", review_text, intent);
589589

590+
// Check for snprintf error
591+
if (ret < 0) {
592+
// Handle encoding error - use a default message
593+
strncpy(intro_msg_buf, review_text, sizeof(intro_msg_buf) - 1);
594+
intro_msg_buf[sizeof(intro_msg_buf) - 1] = '\0';
595+
}
590596
// Check if truncation occurred and add ellipsis if needed
591-
if (ret >= (int)sizeof(intro_msg_buf)) {
597+
else if ((size_t)ret >= sizeof(intro_msg_buf)) {
592598
const size_t buf_len = sizeof(intro_msg_buf);
593599
if (buf_len >= 4) {
594600
intro_msg_buf[buf_len - 4] = '.';
@@ -604,8 +610,14 @@ void view_review_show_with_intent_impl(unsigned int requireReply, const char *in
604610
const char *sign_text = (review_type == REVIEW_MSG) ? "Sign message" : "Sign transaction";
605611
ret = snprintf(approval_label_buf, sizeof(approval_label_buf), "%s to %s?", sign_text, intent);
606612

613+
// Check for snprintf error
614+
if (ret < 0) {
615+
// Handle encoding error - use a default message
616+
strncpy(approval_label_buf, sign_text, sizeof(approval_label_buf) - 1);
617+
approval_label_buf[sizeof(approval_label_buf) - 1] = '\0';
618+
}
607619
// Check if truncation occurred and add ellipsis if needed
608-
if (ret >= (int)sizeof(approval_label_buf)) {
620+
else if ((size_t)ret >= sizeof(approval_label_buf)) {
609621
const size_t buf_len = sizeof(approval_label_buf);
610622
if (buf_len >= 4) {
611623
approval_label_buf[buf_len - 4] = '.';

0 commit comments

Comments
 (0)