@@ -472,12 +472,12 @@ static void config_useCaseReview(nbgl_operationType_t type) {
472
472
if (app_mode_blindsign_required ()) {
473
473
nbgl_useCaseReviewBlindSigning (type , & pairList , & C_icon_stax_64 ,
474
474
(intro_message == NULL ? "Review transaction" : intro_message ),
475
- ( intro_submessage == NULL ? NULL : intro_submessage ) ,
475
+ intro_submessage ,
476
476
"Accept risk and sign transaction ?" , NULL , reviewTransactionChoice );
477
477
} else {
478
478
nbgl_useCaseReview (
479
479
type , & pairList , & C_icon_stax_64 , (intro_message == NULL ? "Review transaction" : intro_message ),
480
- ( intro_submessage == NULL ? NULL : intro_submessage ) ,
480
+ intro_submessage ,
481
481
(approval_label_buf [0 ] != '\0' ? approval_label_buf : APPROVE_LABEL_NBGL ), reviewTransactionChoice );
482
482
}
483
483
}
@@ -587,8 +587,14 @@ void view_review_show_with_intent_impl(unsigned int requireReply, const char *in
587
587
const char * review_text = (review_type == REVIEW_MSG ) ? "Review message" : "Review transaction" ;
588
588
int ret = snprintf (intro_msg_buf , sizeof (intro_msg_buf ), "%s to %s" , review_text , intent );
589
589
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
+ }
590
596
// 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 )) {
592
598
const size_t buf_len = sizeof (intro_msg_buf );
593
599
if (buf_len >= 4 ) {
594
600
intro_msg_buf [buf_len - 4 ] = '.' ;
@@ -604,8 +610,14 @@ void view_review_show_with_intent_impl(unsigned int requireReply, const char *in
604
610
const char * sign_text = (review_type == REVIEW_MSG ) ? "Sign message" : "Sign transaction" ;
605
611
ret = snprintf (approval_label_buf , sizeof (approval_label_buf ), "%s to %s?" , sign_text , intent );
606
612
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
+ }
607
619
// 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 )) {
609
621
const size_t buf_len = sizeof (approval_label_buf );
610
622
if (buf_len >= 4 ) {
611
623
approval_label_buf [buf_len - 4 ] = '.' ;
0 commit comments