From: Dan Carpenter <dan.carpenter@oracle.com>
To: rickard_strandqvist@spectrumdigital.se,
Nicholas Bellinger <nab@linux-iscsi.org>
Cc: target-devel@vger.kernel.org, Joe Perches <joe@perches.com>,
Kees Cook <keescook@chromium.org>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: re: target: target_core_transport.c: Cleaning up missing null-terminate in conjunction with strncpy
Date: Wed, 03 Sep 2014 09:57:42 +0000 [thread overview]
Message-ID: <20140903095742.GA5058@mwanda> (raw)
The patch 6cfa853ceee4: "target: target_core_transport.c: Cleaning up
missing null-terminate in conjunction with strncpy" from Aug 3, 2014,
leads to the following static checker warning:
drivers/target/target_core_transport.c:956 transport_dump_vpd_ident_type()
error: potentially dereferencing uninitialized 'len'.
drivers/target/target_core_transport.c
955 default:
956 len = strlen(len);
^^^^^^^^^^^^^^^^^
This was obviously supposed to be strlen(buf) and no one compile tested
it... But the patch is called "missing null-terminate" when actually
the original code was fine as far as I can see.
Apparently, as a safety measure we're trying to replace every strncpy()
with:
strncpy(foo, bar, sizeof(foo));
foo[sizeof(foo) - 1] = '\0';
We should have a function for this. We used to use strlcpy() but people
complained that it could read beyond the end of the src string. Also it
doesn't pad the string with zeros. So now we're open coding NUL
terminators everywhere so the code is easier to audit.
That sucks and makes the code messier.
Rickard, please, let's find a cleaner way to do this.
regards,
dan carpenter
reply other threads:[~2014-09-03 9:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20140903095742.GA5058@mwanda \
--to=dan.carpenter@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=joe@perches.com \
--cc=keescook@chromium.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nab@linux-iscsi.org \
--cc=rickard_strandqvist@spectrumdigital.se \
--cc=target-devel@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).