From: Stephen Hemminger Date: Mon, 19 Mar 2018 23:21:51 +0000 (-0700) Subject: tc_class: fix snprintf warning X-Git-Tag: v4.16.0~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b8a6088e13ee302657f8c720f3e0f4226dbdaa17;p=thirdparty%2Fiproute2.git tc_class: fix snprintf warning Size buffer big enough to avoid any possible overflow. Signed-off-by: Stephen Hemminger --- diff --git a/tc/tc_class.c b/tc/tc_class.c index 1b214b82c..91802518b 100644 --- a/tc/tc_class.c +++ b/tc/tc_class.c @@ -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,