All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Graf <tgraf@suug.ch>
To: Patrick McHardy <kaber@trash.net>
Cc: jamal <hadi@cyberus.ca>, Maillist netdev <netdev@oss.sgi.com>
Subject: Re: [PATCH PKT_SCHED 4/17]: Check TCA_ACT_KIND payload size _before_ copying it
Date: Thu, 30 Dec 2004 14:34:01 +0100	[thread overview]
Message-ID: <20041230133401.GW32419@postel.suug.ch> (raw)
In-Reply-To: <41D37875.5020103@trash.net>

* Patrick McHardy <41D37875.5020103@trash.net> 2004-12-30 04:39
> -			sprintf(act_name, "%s", (char*)RTA_DATA(kind));
> -			if (RTA_PAYLOAD(kind) >= IFNAMSIZ) {
> -				printk("Action %s bad\n", (char*)RTA_DATA(kind));
> +			if (RTA_PAYLOAD(kind) >= IFNAMSIZ)

The check should be RTA_PAYLOAD(kind) > IFNAMSIZ, == is ok
if the terminating NUL is provided.

>  				goto err_out;
> -			}
> +			sprintf(act_name, "%s", (char*)RTA_DATA(kind));
>  		} else {

This will cause horrible crashes if no NUL is provided to terminate
the name.

So I think this should be:

if (RTA_PAYLOAD(kind) > IFNAMSIZ)
	goto err_out;
memset(act_name, ...);
memcpy(act_name, RTA_DATA(kind), RTA_PAYLOAD(kind));
act_name[IFNAMSIZ - 1] = '\0';

The memset is required to ensure 0 termination if kind is not and
shorter than IFNAMSIZ. memcpy instead of str* to avoid using
any form of str(n)len on a possibly not terminated string
and setting IFNAMSIZ - 1 to NUL to ensure proper handling of
a IFNAMSIZ long not terminated string.

I know it's unlikely but this might just save us some troubles later.

  reply	other threads:[~2004-12-30 13:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-30  3:39 [PATCH PKT_SCHED 4/17]: Check TCA_ACT_KIND payload size _before_ copying it Patrick McHardy
2004-12-30 13:34 ` Thomas Graf [this message]
2004-12-30 14:20   ` Patrick McHardy

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=20041230133401.GW32419@postel.suug.ch \
    --to=tgraf@suug.ch \
    --cc=hadi@cyberus.ca \
    --cc=kaber@trash.net \
    --cc=netdev@oss.sgi.com \
    /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.