@@ -342,9 +342,9 @@ bool filtering_trusted_name(const uint8_t *payload,
342
342
uint32_t * path_crc ) {
343
343
uint8_t name_len ;
344
344
const char * name ;
345
- uint8_t types_count ;
345
+ uint8_t type_count ;
346
346
e_name_type * types ;
347
- uint8_t sources_count ;
347
+ uint8_t source_count ;
348
348
e_name_source * sources ;
349
349
uint8_t sig_len ;
350
350
const uint8_t * sig ;
@@ -365,48 +365,30 @@ bool filtering_trusted_name(const uint8_t *payload,
365
365
}
366
366
name = (char * ) & payload [offset ];
367
367
offset += name_len ;
368
- if ((offset + sizeof (types_count )) > length ) {
368
+ if ((offset + sizeof (type_count )) > length ) {
369
369
return false;
370
370
}
371
- types_count = payload [offset ++ ];
372
- if ((offset + types_count ) > length ) {
371
+ type_count = payload [offset ++ ];
372
+ if (type_count > TN_TYPE_COUNT ) {
373
+ return false;
374
+ }
375
+ if ((offset + type_count ) > length ) {
373
376
return false;
374
377
}
375
378
types = (e_name_type * ) & payload [offset ];
376
- // sanity check
377
- for (int i = 0 ; i < types_count ; ++ i ) {
378
- switch (types [i ]) {
379
- case TN_TYPE_ACCOUNT :
380
- case TN_TYPE_CONTRACT :
381
- break ;
382
- default :
383
- return false;
384
- }
379
+ offset += type_count ;
380
+ if ((offset + sizeof (source_count )) > length ) {
381
+ return false;
385
382
}
386
- offset += types_count ;
387
- if (( offset + sizeof ( sources_count )) > length ) {
383
+ source_count = payload [ offset ++ ] ;
384
+ if (source_count > TN_SOURCE_COUNT ) {
388
385
return false;
389
386
}
390
- sources_count = payload [offset ++ ];
391
- if ((offset + sources_count ) > length ) {
387
+ if ((offset + source_count ) > length ) {
392
388
return false;
393
389
}
394
390
sources = (e_name_source * ) & payload [offset ];
395
- // sanity check
396
- for (int i = 0 ; i < sources_count ; ++ i ) {
397
- switch (sources [i ]) {
398
- case TN_SOURCE_LAB :
399
- case TN_SOURCE_CAL :
400
- case TN_SOURCE_ENS :
401
- case TN_SOURCE_UD :
402
- case TN_SOURCE_FN :
403
- case TN_SOURCE_DNS :
404
- break ;
405
- default :
406
- return false;
407
- }
408
- }
409
- offset += sources_count ;
391
+ offset += source_count ;
410
392
//
411
393
if ((offset + sizeof (sig_len )) > length ) {
412
394
return false;
@@ -424,8 +406,8 @@ bool filtering_trusted_name(const uint8_t *payload,
424
406
}
425
407
hash_filtering_path ((cx_hash_t * ) & hash_ctx , discarded , path_crc );
426
408
hash_nbytes ((uint8_t * ) name , sizeof (char ) * name_len , (cx_hash_t * ) & hash_ctx );
427
- hash_nbytes (types , types_count , (cx_hash_t * ) & hash_ctx );
428
- hash_nbytes (sources , sources_count , (cx_hash_t * ) & hash_ctx );
409
+ hash_nbytes (types , type_count , (cx_hash_t * ) & hash_ctx );
410
+ hash_nbytes (sources , source_count , (cx_hash_t * ) & hash_ctx );
429
411
if (!sig_verif_end (& hash_ctx , sig , sig_len )) {
430
412
return false;
431
413
}
@@ -438,7 +420,7 @@ bool filtering_trusted_name(const uint8_t *payload,
438
420
ui_712_set_title (name , name_len );
439
421
}
440
422
ui_712_flag_field (true, name_len > 0 , false, false, true);
441
- ui_712_set_trusted_name_requirements (types_count , types );
423
+ ui_712_set_trusted_name_requirements (type_count , types , source_count , sources );
442
424
return true;
443
425
}
444
426
#endif // HAVE_TRUSTED_NAME
0 commit comments