All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Machata <petrm@nvidia.com>
To: Roi Dayan <roid@nvidia.com>
Cc: <netdev@vger.kernel.org>, Petr Machata <petrm@nvidia.com>,
	"Stephen Hemminger" <stephen@networkplumber.org>
Subject: Re: [PATCH iproute2-next v2] dcb: Fix compilation warning about reallocarray
Date: Mon, 22 Feb 2021 13:30:02 +0100	[thread overview]
Message-ID: <875z2kl1yt.fsf@nvidia.com> (raw)
In-Reply-To: <20210222121030.2109-1-roid@nvidia.com>


Roi Dayan <roid@nvidia.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@nvidia.com>

  reply	other threads:[~2021-02-22 12:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-22 12:10 [PATCH iproute2-next v2] dcb: Fix compilation warning about reallocarray Roi Dayan
2021-02-22 12:30 ` Petr Machata [this message]
2021-03-15 13:10   ` Petr Machata
2021-03-15 15:09     ` David Ahern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875z2kl1yt.fsf@nvidia.com \
    --to=petrm@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=roid@nvidia.com \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.