[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20101005164306.GP19804@ZenIV.linux.org.uk>
Date: Tue, 5 Oct 2010 17:43:06 +0100
From: Al Viro <viro@...IV.linux.org.uk>
To: Dan Carpenter <error27@...il.com>
Cc: Karsten Keil <isdn@...ux-pingi.de>, netdev@...r.kernel.org,
kernel-janitors@...r.kernel.org
Subject: Re: [patch] isdn: strcpy() => strlcpy()
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.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists