@@ -380,13 +380,18 @@ static int tipc_nl_compat_bearer_enable(struct tipc_nl_compat_cmd_doit *cmd,
380
380
struct nlattr * prop ;
381
381
struct nlattr * bearer ;
382
382
struct tipc_bearer_config * b ;
383
+ int len ;
383
384
384
385
b = (struct tipc_bearer_config * )TLV_DATA (msg -> req );
385
386
386
387
bearer = nla_nest_start (skb , TIPC_NLA_BEARER );
387
388
if (!bearer )
388
389
return - EMSGSIZE ;
389
390
391
+ len = min_t (int , TLV_GET_DATA_LEN (msg -> req ), TIPC_MAX_BEARER_NAME );
392
+ if (!string_is_valid (b -> name , len ))
393
+ return - EINVAL ;
394
+
390
395
if (nla_put_string (skb , TIPC_NLA_BEARER_NAME , b -> name ))
391
396
return - EMSGSIZE ;
392
397
@@ -412,13 +417,18 @@ static int tipc_nl_compat_bearer_disable(struct tipc_nl_compat_cmd_doit *cmd,
412
417
{
413
418
char * name ;
414
419
struct nlattr * bearer ;
420
+ int len ;
415
421
416
422
name = (char * )TLV_DATA (msg -> req );
417
423
418
424
bearer = nla_nest_start (skb , TIPC_NLA_BEARER );
419
425
if (!bearer )
420
426
return - EMSGSIZE ;
421
427
428
+ len = min_t (int , TLV_GET_DATA_LEN (msg -> req ), TIPC_MAX_BEARER_NAME );
429
+ if (!string_is_valid (name , len ))
430
+ return - EINVAL ;
431
+
422
432
if (nla_put_string (skb , TIPC_NLA_BEARER_NAME , name ))
423
433
return - EMSGSIZE ;
424
434
@@ -479,6 +489,7 @@ static int tipc_nl_compat_link_stat_dump(struct tipc_nl_compat_msg *msg,
479
489
struct nlattr * prop [TIPC_NLA_PROP_MAX + 1 ];
480
490
struct nlattr * stats [TIPC_NLA_STATS_MAX + 1 ];
481
491
int err ;
492
+ int len ;
482
493
483
494
if (!attrs [TIPC_NLA_LINK ])
484
495
return - EINVAL ;
@@ -505,6 +516,11 @@ static int tipc_nl_compat_link_stat_dump(struct tipc_nl_compat_msg *msg,
505
516
return err ;
506
517
507
518
name = (char * )TLV_DATA (msg -> req );
519
+
520
+ len = min_t (int , TLV_GET_DATA_LEN (msg -> req ), TIPC_MAX_LINK_NAME );
521
+ if (!string_is_valid (name , len ))
522
+ return - EINVAL ;
523
+
508
524
if (strcmp (name , nla_data (link [TIPC_NLA_LINK_NAME ])) != 0 )
509
525
return 0 ;
510
526
@@ -645,13 +661,18 @@ static int tipc_nl_compat_media_set(struct sk_buff *skb,
645
661
struct nlattr * prop ;
646
662
struct nlattr * media ;
647
663
struct tipc_link_config * lc ;
664
+ int len ;
648
665
649
666
lc = (struct tipc_link_config * )TLV_DATA (msg -> req );
650
667
651
668
media = nla_nest_start (skb , TIPC_NLA_MEDIA );
652
669
if (!media )
653
670
return - EMSGSIZE ;
654
671
672
+ len = min_t (int , TLV_GET_DATA_LEN (msg -> req ), TIPC_MAX_MEDIA_NAME );
673
+ if (!string_is_valid (lc -> name , len ))
674
+ return - EINVAL ;
675
+
655
676
if (nla_put_string (skb , TIPC_NLA_MEDIA_NAME , lc -> name ))
656
677
return - EMSGSIZE ;
657
678
@@ -672,13 +693,18 @@ static int tipc_nl_compat_bearer_set(struct sk_buff *skb,
672
693
struct nlattr * prop ;
673
694
struct nlattr * bearer ;
674
695
struct tipc_link_config * lc ;
696
+ int len ;
675
697
676
698
lc = (struct tipc_link_config * )TLV_DATA (msg -> req );
677
699
678
700
bearer = nla_nest_start (skb , TIPC_NLA_BEARER );
679
701
if (!bearer )
680
702
return - EMSGSIZE ;
681
703
704
+ len = min_t (int , TLV_GET_DATA_LEN (msg -> req ), TIPC_MAX_MEDIA_NAME );
705
+ if (!string_is_valid (lc -> name , len ))
706
+ return - EINVAL ;
707
+
682
708
if (nla_put_string (skb , TIPC_NLA_BEARER_NAME , lc -> name ))
683
709
return - EMSGSIZE ;
684
710
0 commit comments