@@ -53,6 +53,7 @@ const char *intro_message = NULL;
53
53
const char * intro_submessage = NULL ;
54
54
char intro_msg_buf [MAX_CHARS_PER_VALUE1_LINE ];
55
55
char intro_submsg_buf [MAX_CHARS_SUBMSG_LINE ];
56
+ char approval_label_buf [MAX_CHARS_SUBMSG_LINE ];
56
57
57
58
#define REVIEW_STANDALONE_SIZE 22
58
59
#define REVIEW_MESSAGE_SIZE 18
@@ -470,13 +471,13 @@ static void config_useCaseReview(nbgl_operationType_t type) {
470
471
471
472
if (app_mode_blindsign_required ()) {
472
473
nbgl_useCaseReviewBlindSigning (type , & pairList , & C_icon_stax_64 ,
473
- (intro_message == NULL ? "Review transaction" : intro_message ),
474
- (intro_submessage == NULL ? NULL : intro_submessage ),
474
+ (intro_message == NULL ? "Review transaction" : intro_message ), intro_submessage ,
475
475
"Accept risk and sign transaction ?" , NULL , reviewTransactionChoice );
476
476
} else {
477
- nbgl_useCaseReview (
478
- type , & pairList , & C_icon_stax_64 , (intro_message == NULL ? "Review transaction" : intro_message ),
479
- (intro_submessage == NULL ? NULL : intro_submessage ), APPROVE_LABEL_NBGL , reviewTransactionChoice );
477
+ nbgl_useCaseReview (type , & pairList , & C_icon_stax_64 ,
478
+ (intro_message == NULL ? "Review transaction" : intro_message ), intro_submessage ,
479
+ (approval_label_buf [0 ] != '\0' ? approval_label_buf : APPROVE_LABEL_NBGL ),
480
+ reviewTransactionChoice );
480
481
}
481
482
}
482
483
@@ -497,9 +498,9 @@ static void config_useCaseMessageReview() {
497
498
(intro_message == NULL ? "Review Message" : intro_message ), NULL ,
498
499
"Accept risk and sign message ?" , NULL , reviewMessageChoice );
499
500
} else {
500
- nbgl_useCaseReview (TYPE_MESSAGE , & pairList , & C_Review_64px ,
501
- (intro_message == NULL ? "Review Message" : intro_message ), NULL , APPROVE_LABEL_NBGL_MSG ,
502
- reviewMessageChoice );
501
+ nbgl_useCaseReview (
502
+ TYPE_MESSAGE , & pairList , & C_Review_64px , (intro_message == NULL ? "Review Message" : intro_message ), NULL ,
503
+ ( approval_label_buf [ 0 ] != '\0' ? approval_label_buf : APPROVE_LABEL_NBGL_MSG ), reviewMessageChoice );
503
504
}
504
505
}
505
506
@@ -528,6 +529,7 @@ void view_review_show_impl(unsigned int requireReply, const char *title, const c
528
529
intro_submessage = NULL ;
529
530
intro_msg_buf [0 ] = '\0' ;
530
531
intro_submsg_buf [0 ] = '\0' ;
532
+ approval_label_buf [0 ] = '\0' ;
531
533
viewdata .key = viewdata .keys [0 ];
532
534
viewdata .value = viewdata .values [0 ];
533
535
// Retrieve intro text for transaction
@@ -574,6 +576,7 @@ void view_review_show_with_intent_impl(unsigned int requireReply, const char *in
574
576
intro_submessage = NULL ;
575
577
intro_msg_buf [0 ] = '\0' ;
576
578
intro_submsg_buf [0 ] = '\0' ;
579
+ approval_label_buf [0 ] = '\0' ;
577
580
viewdata .key = viewdata .keys [0 ];
578
581
viewdata .value = viewdata .values [0 ];
579
582
@@ -583,8 +586,14 @@ void view_review_show_with_intent_impl(unsigned int requireReply, const char *in
583
586
const char * review_text = (review_type == REVIEW_MSG ) ? "Review message" : "Review transaction" ;
584
587
int ret = snprintf (intro_msg_buf , sizeof (intro_msg_buf ), "%s to %s" , review_text , intent );
585
588
589
+ // Check for snprintf error
590
+ if (ret < 0 ) {
591
+ // Handle encoding error - use a default message
592
+ strncpy (intro_msg_buf , review_text , sizeof (intro_msg_buf ) - 1 );
593
+ intro_msg_buf [sizeof (intro_msg_buf ) - 1 ] = '\0' ;
594
+ }
586
595
// Check if truncation occurred and add ellipsis if needed
587
- if (ret >= ( int ) sizeof (intro_msg_buf )) {
596
+ else if (( size_t ) ret >= sizeof (intro_msg_buf )) {
588
597
const size_t buf_len = sizeof (intro_msg_buf );
589
598
if (buf_len >= 4 ) {
590
599
intro_msg_buf [buf_len - 4 ] = '.' ;
@@ -595,6 +604,31 @@ void view_review_show_with_intent_impl(unsigned int requireReply, const char *in
595
604
}
596
605
intro_message = intro_msg_buf ;
597
606
intro_submessage = NULL ; // No second line for NBGL
607
+
608
+ // Format the approval label with intent for the final approval screen
609
+ const char * sign_text = (review_type == REVIEW_MSG ) ? "Sign message" : "Sign transaction" ;
610
+ ret = snprintf (approval_label_buf , sizeof (approval_label_buf ), "%s to %s?" , sign_text , intent );
611
+
612
+ // Check for snprintf error
613
+ if (ret < 0 ) {
614
+ // Handle encoding error - use a default message
615
+ strncpy (approval_label_buf , sign_text , sizeof (approval_label_buf ) - 1 );
616
+ approval_label_buf [sizeof (approval_label_buf ) - 1 ] = '\0' ;
617
+ }
618
+ // Check if truncation occurred and add ellipsis if needed
619
+ else if ((size_t )ret >= sizeof (approval_label_buf )) {
620
+ const size_t buf_len = sizeof (approval_label_buf );
621
+ if (buf_len >= 4 ) {
622
+ approval_label_buf [buf_len - 4 ] = '.' ;
623
+ approval_label_buf [buf_len - 3 ] = '.' ;
624
+ approval_label_buf [buf_len - 2 ] = '.' ;
625
+ approval_label_buf [buf_len - 1 ] = '\0' ;
626
+ }
627
+ }
628
+ } else {
629
+ // Use default labels if no intent
630
+ snprintf (approval_label_buf , sizeof (approval_label_buf ), "%s" ,
631
+ (review_type == REVIEW_MSG ) ? APPROVE_LABEL_NBGL_MSG : APPROVE_LABEL_NBGL );
598
632
}
599
633
600
634
h_paging_init ();
0 commit comments