]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
tc_class: fix snprintf warning
authorStephen Hemminger <stephen@networkplumber.org>
Mon, 19 Mar 2018 23:21:51 +0000 (16:21 -0700)
committerStephen Hemminger <stephen@networkplumber.org>
Thu, 29 Mar 2018 15:32:43 +0000 (08:32 -0700)
Size buffer big enough to avoid any possible overflow.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
tc/tc_class.c

index 1b214b82c702baa1eb781ad9fa8b10e0cca40442..91802518bb275b2a9ce1a5954ba93b28c7585ead 100644 (file)
@@ -219,7 +219,7 @@ static void graph_cls_show(FILE *fp, char *buf, struct hlist_head *root_list,
        char cls_id_str[256] = {};
        struct rtattr *tb[TCA_MAX + 1];
        struct qdisc_util *q;
-       char str[100] = {};
+       char str[300] = {};
 
        hlist_for_each_safe(n, tmp_cls, root_list) {
                struct hlist_node *c, *tmp_chld;
@@ -242,7 +242,8 @@ static void graph_cls_show(FILE *fp, char *buf, struct hlist_head *root_list,
                graph_indent(buf, cls, 0, 0);
 
                print_tc_classid(cls_id_str, sizeof(cls_id_str), cls->id);
-               sprintf(str, "+---(%s)", cls_id_str);
+               snprintf(str, sizeof(str),
+                        "+---(%s)", cls_id_str);
                strcat(buf, str);
 
                parse_rtattr(tb, TCA_MAX, (struct rtattr *)cls->data,