From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Gabriel Krisman Bertazi <krisman@collabora.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
"Gustavo A. R. Silva" <gustavo@embeddedor.com>
Subject: [PATCH] unicode: replace strncpy() by strscpy()
Date: Mon, 27 May 2019 12:47:33 -0500 [thread overview]
Message-ID: <20190527174733.GA29547@embeddedor> (raw)
The strncpy() function is being deprecated. Replace it by the safer
strscpy() and fix the following Coverity warning:
"Calling strncpy with a maximum size argument of 12 bytes on destination
array version_string of size 12 bytes might leave the destination string
unterminated."
Notice that, unlike strncpy(), strscpy() always null-terminates the
destination string.
Addresses-Coverity-ID: 1445547 ("Buffer not null terminated")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
fs/unicode/utf8-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/unicode/utf8-core.c b/fs/unicode/utf8-core.c
index 6afab4fdce90..a367041468cf 100644
--- a/fs/unicode/utf8-core.c
+++ b/fs/unicode/utf8-core.c
@@ -131,7 +131,7 @@ static int utf8_parse_version(const char *version, unsigned int *maj,
{0, NULL}
};
- strncpy(version_string, version, sizeof(version_string));
+ strscpy(version_string, version, sizeof(version_string));
if (match_token(version_string, token, args) != 1)
return -EINVAL;
--
2.21.0
next reply other threads:[~2019-05-27 18:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-27 17:47 Gustavo A. R. Silva [this message]
2019-05-28 17:47 ` [PATCH] unicode: replace strncpy() by strscpy() Gabriel Krisman Bertazi
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=20190527174733.GA29547@embeddedor \
--to=gustavo@embeddedor.com \
--cc=krisman@collabora.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@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).