Subject: Re: [PATCH iproute2-next v2 2/2] f_flower: Implement gtp options support

From: Stephen Hemminger <[email-masked]>
Date: Fri, 4 Feb 2022 10:20:58 -0800

On Fri,  4 Feb 2022 17:58:21 +0100
Wojciech Drewek <[email-masked]> wrote:

> +static void flower_print_gtp_opts(const char *name, struct rtattr *attr,
> +				  char *strbuf)
> +{
> +	struct rtattr *tb[TCA_FLOWER_KEY_ENC_OPT_GTP_MAX + 1];
> +	__u8 pdu_type, qfi;
> +
> +	parse_rtattr(tb, TCA_FLOWER_KEY_ENC_OPT_GTP_MAX, RTA_DATA(attr),
> +		     RTA_PAYLOAD(attr));
> +
> +	pdu_type = rta_getattr_u8(tb[TCA_FLOWER_KEY_ENC_OPT_GTP_PDU_TYPE]);
> +	qfi = rta_getattr_u8(tb[TCA_FLOWER_KEY_ENC_OPT_GTP_QFI]);
> +
> +	sprintf(strbuf, "%02x:%02x", pdu_type, qfi);
> +}

Better to use snprintf and pass length parameter.
You are ok now, but someday this might grow.