netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Dan Carpenter <error27@gmail.com>
Cc: Karsten Keil <isdn@linux-pingi.de>,
	netdev@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] isdn: strcpy() => strlcpy()
Date: Tue, 5 Oct 2010 17:43:06 +0100	[thread overview]
Message-ID: <20101005164306.GP19804@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20101005163448.GH5692@bicker>

On Tue, Oct 05, 2010 at 06:34:48PM +0200, Dan Carpenter wrote:
> setup.phone and setup.eazmsn are 32 character buffers.
> rcvmsg.msg_data.byte_array is a 48 character buffer.
> sc_adapter[card]->channel[rcvmsg.phy_link_no - 1].dn is 50 chars.
> 
> I changed the strcpy() so strlcpy() because that's safest.

ITYM "I papered it over, so potentially broken behaviour is harder to
find now"...

> -				strcpy(setup.phone,&(rcvmsg.msg_data.byte_array[4]));
> -				strcpy(setup.eazmsn,
> -					sc_adapter[card]->channel[rcvmsg.phy_link_no-1].dn);
> +				strlcpy(setup.phone, &(rcvmsg.msg_data.byte_array[4]),
> +					sizeof(setup.phone));

OK, so what should be done if the damn array contents _is_ longer than that?

> +				strlcpy(setup.eazmsn,
> +					sc_adapter[card]->channel[rcvmsg.phy_link_no - 1].dn,
> +					sizeof(setup.eazmsn));

Ditto.

> -			strcpy(sc_adapter[card]->channel[rcvmsg.phy_link_no-1].dn,rcvmsg.msg_data.byte_array);
> +			strlcpy(sc_adapter[card]->channel[rcvmsg.phy_link_no - 1].dn,
> +				rcvmsg.msg_data.byte_array,
> +				sizeof(rcvmsg.msg_data.byte_array));

Huh?  Is it or is it not NUL-terminated?  If it is, then change is pure
cargo-culting; if it is not, you are asking for nasal daemons to fly.

  reply	other threads:[~2010-10-05 16:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-05 16:34 [patch] isdn: strcpy() => strlcpy() Dan Carpenter
2010-10-05 16:43 ` Al Viro [this message]
2010-10-06  5:17   ` Dan Carpenter
2010-10-08 17:23     ` David Miller

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=20101005164306.GP19804@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=error27@gmail.com \
    --cc=isdn@linux-pingi.de \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=netdev@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).