[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <875z2kl1yt.fsf@nvidia.com>
Date: Mon, 22 Feb 2021 13:30:02 +0100
From: Petr Machata <petrm@...dia.com>
To: Roi Dayan <roid@...dia.com>
CC: <netdev@...r.kernel.org>, Petr Machata <petrm@...dia.com>,
"Stephen Hemminger" <stephen@...workplumber.org>
Subject: Re: [PATCH iproute2-next v2] dcb: Fix compilation warning about
reallocarray
Roi Dayan <roid@...dia.com> writes:
> --- a/dcb/dcb_app.c
> +++ b/dcb/dcb_app.c
> @@ -65,8 +65,7 @@ static void dcb_app_table_fini(struct dcb_app_table *tab)
>
> static int dcb_app_table_push(struct dcb_app_table *tab, struct dcb_app *app)
> {
> - struct dcb_app *apps = reallocarray(tab->apps, tab->n_apps + 1,
> - sizeof(*tab->apps));
> + struct dcb_app *apps = realloc(tab->apps, (tab->n_apps + 1) * sizeof(*tab->apps));
reallocarray() checks that count*size does not overflow. But the whole
APP table needs to fit into one attribute, which limits the size to some
64K, so from UAPI direction this will never overflow. From the
command-line direction, size of 'struct app' is 4 bytes, so to overflow
you'd need to stuff in 1G APP entries. I think we don't need to worry
about that.
So this looks good.
Reviewed-by: Petr Machata <petrm@...dia.com>
Powered by blists - more mailing lists