From: Rick Jones <rick.jones2@hp.com>
To: Ben Hutchings <bhutchings@solarflare.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>, netdev@vger.kernel.org
Subject: Re: [PATCH] ncm: allow for NULL terminations
Date: Mon, 17 Sep 2012 10:39:39 -0700 [thread overview]
Message-ID: <5057605B.10104@hp.com> (raw)
In-Reply-To: <1347896724.2685.2.camel@bwh-desktop.uk.solarflarecom.com>
On 09/17/2012 08:45 AM, Ben Hutchings wrote:
> On Mon, 2012-09-17 at 11:58 +0100, Alan Cox wrote:
>> From: Alan Cox <alan@linux.intel.com>
>>
>> The strings are passed to snprintf so must be null terminated. It seems the
>> copy length is incorrectly set.
>
> Please use strlcpy() instead. (I thought someone had already gone round
> the get_drvinfo implementations and fixed them to do that, actually.)
That may have been my "floor sweeping" exercise of before, but I didn't
go into drivers/net/usb/ at the time.
rick
>
> Ben.
>
>> Signed-off-by: Alan Cox <alan@linux.intel.com>
>> ---
>>
>> drivers/net/usb/cdc_ncm.c | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
>> index 4cd582a..af8cce7 100644
>> --- a/drivers/net/usb/cdc_ncm.c
>> +++ b/drivers/net/usb/cdc_ncm.c
>> @@ -145,10 +145,10 @@ cdc_ncm_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *info)
>> {
>> struct usbnet *dev = netdev_priv(net);
>>
>> - strncpy(info->driver, dev->driver_name, sizeof(info->driver));
>> - strncpy(info->version, DRIVER_VERSION, sizeof(info->version));
>> + strncpy(info->driver, dev->driver_name, sizeof(info->driver) - 1);
>> + strncpy(info->version, DRIVER_VERSION, sizeof(info->version) - 1);
>> strncpy(info->fw_version, dev->driver_info->description,
>> - sizeof(info->fw_version));
>> + sizeof(info->fw_version) - 1);
>> usb_make_path(dev->udev, info->bus_info, sizeof(info->bus_info));
>> }
>>
>>
>
prev parent reply other threads:[~2012-09-17 17:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-17 10:58 [PATCH] ncm: allow for NULL terminations Alan Cox
2012-09-17 15:45 ` Ben Hutchings
2012-09-17 16:31 ` Alan Cox
2012-09-17 17:39 ` Rick Jones [this message]
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=5057605B.10104@hp.com \
--to=rick.jones2@hp.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=bhutchings@solarflare.com \
--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 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.