@@ -389,13 +389,18 @@ static int tipc_nl_compat_bearer_enable(struct tipc_nl_compat_cmd_doit *cmd,
389
389
struct nlattr * prop ;
390
390
struct nlattr * bearer ;
391
391
struct tipc_bearer_config * b ;
392
+ int len ;
392
393
393
394
b = (struct tipc_bearer_config * )TLV_DATA (msg -> req );
394
395
395
396
bearer = nla_nest_start (skb , TIPC_NLA_BEARER );
396
397
if (!bearer )
397
398
return - EMSGSIZE ;
398
399
400
+ len = min_t (int , TLV_GET_DATA_LEN (msg -> req ), TIPC_MAX_BEARER_NAME );
401
+ if (!string_is_valid (b -> name , len ))
402
+ return - EINVAL ;
403
+
399
404
if (nla_put_string (skb , TIPC_NLA_BEARER_NAME , b -> name ))
400
405
return - EMSGSIZE ;
401
406
@@ -421,13 +426,18 @@ static int tipc_nl_compat_bearer_disable(struct tipc_nl_compat_cmd_doit *cmd,
421
426
{
422
427
char * name ;
423
428
struct nlattr * bearer ;
429
+ int len ;
424
430
425
431
name = (char * )TLV_DATA (msg -> req );
426
432
427
433
bearer = nla_nest_start (skb , TIPC_NLA_BEARER );
428
434
if (!bearer )
429
435
return - EMSGSIZE ;
430
436
437
+ len = min_t (int , TLV_GET_DATA_LEN (msg -> req ), TIPC_MAX_BEARER_NAME );
438
+ if (!string_is_valid (name , len ))
439
+ return - EINVAL ;
440
+
431
441
if (nla_put_string (skb , TIPC_NLA_BEARER_NAME , name ))
432
442
return - EMSGSIZE ;
433
443
@@ -488,6 +498,7 @@ static int tipc_nl_compat_link_stat_dump(struct tipc_nl_compat_msg *msg,
488
498
struct nlattr * prop [TIPC_NLA_PROP_MAX + 1 ];
489
499
struct nlattr * stats [TIPC_NLA_STATS_MAX + 1 ];
490
500
int err ;
501
+ int len ;
491
502
492
503
if (!attrs [TIPC_NLA_LINK ])
493
504
return - EINVAL ;
@@ -514,6 +525,11 @@ static int tipc_nl_compat_link_stat_dump(struct tipc_nl_compat_msg *msg,
514
525
return err ;
515
526
516
527
name = (char * )TLV_DATA (msg -> req );
528
+
529
+ len = min_t (int , TLV_GET_DATA_LEN (msg -> req ), TIPC_MAX_LINK_NAME );
530
+ if (!string_is_valid (name , len ))
531
+ return - EINVAL ;
532
+
517
533
if (strcmp (name , nla_data (link [TIPC_NLA_LINK_NAME ])) != 0 )
518
534
return 0 ;
519
535
@@ -654,13 +670,18 @@ static int tipc_nl_compat_media_set(struct sk_buff *skb,
654
670
struct nlattr * prop ;
655
671
struct nlattr * media ;
656
672
struct tipc_link_config * lc ;
673
+ int len ;
657
674
658
675
lc = (struct tipc_link_config * )TLV_DATA (msg -> req );
659
676
660
677
media = nla_nest_start (skb , TIPC_NLA_MEDIA );
661
678
if (!media )
662
679
return - EMSGSIZE ;
663
680
681
+ len = min_t (int , TLV_GET_DATA_LEN (msg -> req ), TIPC_MAX_MEDIA_NAME );
682
+ if (!string_is_valid (lc -> name , len ))
683
+ return - EINVAL ;
684
+
664
685
if (nla_put_string (skb , TIPC_NLA_MEDIA_NAME , lc -> name ))
665
686
return - EMSGSIZE ;
666
687
@@ -681,13 +702,18 @@ static int tipc_nl_compat_bearer_set(struct sk_buff *skb,
681
702
struct nlattr * prop ;
682
703
struct nlattr * bearer ;
683
704
struct tipc_link_config * lc ;
705
+ int len ;
684
706
685
707
lc = (struct tipc_link_config * )TLV_DATA (msg -> req );
686
708
687
709
bearer = nla_nest_start (skb , TIPC_NLA_BEARER );
688
710
if (!bearer )
689
711
return - EMSGSIZE ;
690
712
713
+ len = min_t (int , TLV_GET_DATA_LEN (msg -> req ), TIPC_MAX_MEDIA_NAME );
714
+ if (!string_is_valid (lc -> name , len ))
715
+ return - EINVAL ;
716
+
691
717
if (nla_put_string (skb , TIPC_NLA_BEARER_NAME , lc -> name ))
692
718
return - EMSGSIZE ;
693
719
0 commit comments