From: Dan Carpenter <dan.carpenter@oracle.com>
To: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Cc: devel@driverdev.osuosl.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, navin patidar <navinp@cdac.in>,
Valentina Manea <valentina.manea.m@gmail.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] staging: usbip: stub_main.c: Cleaning up missing null-terminate after strncpy call
Date: Wed, 11 Jun 2014 08:45:04 +0300 [thread overview]
Message-ID: <20140611053612.GN5015@mwanda> (raw)
In-Reply-To: <CAFo99gY9ROmVS56PeeAPxw6GgBnjLai3az0ABnE=1xcryDCRuA@mail.gmail.com>
On Tue, Jun 10, 2014 at 10:48:35PM +0200, Rickard Strandqvist wrote:
> Hi
>
> True!
> Sorry :-(
>
> But then one would either operate strcpy outright.
>
> Or use strlcpy then the code would be:
>
> /* strlcpy() handles not include \0 */
> len = strlcpy(busid, buf + 4, BUSID_SIZE);
>
> /* busid needs to include \0 termination */
> if (!(len < BUSID_SIZE))
I don't like this condition. Just say (len >= BUSID_SIZE). The
comments here are obvious and could be left out.
> return -EINVAL;
I don't have strong feelings about a cleanup patch. But I think that
cppcheck is not being very sofisticated here with the NUL termination
warning so we should not go out of our way to try to silence the
warning.
regards,
dan carpenter
next prev parent reply other threads:[~2014-06-11 5:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-04 21:39 [PATCH] staging: usbip: stub_main.c: Cleaning up missing null-terminate after strncpy call Rickard Strandqvist
2014-06-10 6:57 ` Dan Carpenter
2014-06-10 20:48 ` Rickard Strandqvist
2014-06-11 5:45 ` Dan Carpenter [this message]
2014-06-12 21:09 ` Rickard Strandqvist
2014-06-12 21:39 ` Dan Carpenter
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=20140611053612.GN5015@mwanda \
--to=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=navinp@cdac.in \
--cc=rickard_strandqvist@spectrumdigital.se \
--cc=valentina.manea.m@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox