From: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
To: Steve French <sfrench@samba.org>, linux-cifs@vger.kernel.org
Cc: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>,
samba-technical@lists.samba.org, linux-kernel@vger.kernel.org
Subject: [PATCH] fs: cifs: cifsencrypt.c: Cleaning up missing null-terminate in conjunction with strncpy
Date: Wed, 25 Jun 2014 12:42:34 +0200 [thread overview]
Message-ID: <1403692954-18881-1-git-send-email-rickard_strandqvist@spectrumdigital.se> (raw)
Because the string is zeroed before, it's better to just copy one character less, instead of using strlcpy in this case.
This was found using a static code analysis program called cppcheck.
Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
fs/cifs/cifsencrypt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
index 4934347..dcca8b3 100644
--- a/fs/cifs/cifsencrypt.c
+++ b/fs/cifs/cifsencrypt.c
@@ -307,7 +307,7 @@ int calc_lanman_hash(const char *password, const char *cryptkey, bool encrypt,
memset(password_with_pad, 0, CIFS_ENCPWD_SIZE);
if (password)
- strncpy(password_with_pad, password, CIFS_ENCPWD_SIZE);
+ strncpy(password_with_pad, password, CIFS_ENCPWD_SIZE - 1);
if (!encrypt && global_secflags & CIFSSEC_MAY_PLNTXT) {
memcpy(lnm_session_key, password_with_pad,
--
1.7.10.4
next reply other threads:[~2014-06-25 10:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-25 10:42 Rickard Strandqvist [this message]
2014-07-26 22:28 [PATCH] fs: cifs: cifsencrypt.c: Cleaning up missing null-terminate in conjunction with strncpy Rickard Strandqvist
2014-08-02 16:55 ` Shirish Pargaonkar
2014-08-02 17:33 ` Joe Perches
2014-08-02 23:13 ` Rickard Strandqvist
2014-08-03 0:27 ` Joe Perches
2014-08-03 6:22 ` Shirish Pargaonkar
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=1403692954-18881-1-git-send-email-rickard_strandqvist@spectrumdigital.se \
--to=rickard_strandqvist@spectrumdigital.se \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=samba-technical@lists.samba.org \
--cc=sfrench@samba.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).