提交 b3f8ab4b 编写于 作者: C Chen Gang 提交者: Eric Van Hensbergen

fs: 9p: use strlcpy instead of strncpy

For 'NULL' terminated string, recommend always to be ended by zero.
Signed-off-by: NChen Gang <gang.chen@asianux.com>
Signed-off-by: NEric Van Hensbergen <ericvh@gmail.com>
上级 ad81f054
...@@ -146,7 +146,7 @@ static umode_t p9mode2unixmode(struct v9fs_session_info *v9ses, ...@@ -146,7 +146,7 @@ static umode_t p9mode2unixmode(struct v9fs_session_info *v9ses,
char type = 0, ext[32]; char type = 0, ext[32];
int major = -1, minor = -1; int major = -1, minor = -1;
strncpy(ext, stat->extension, sizeof(ext)); strlcpy(ext, stat->extension, sizeof(ext));
sscanf(ext, "%c %u %u", &type, &major, &minor); sscanf(ext, "%c %u %u", &type, &major, &minor);
switch (type) { switch (type) {
case 'c': case 'c':
...@@ -1186,7 +1186,7 @@ v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode, ...@@ -1186,7 +1186,7 @@ v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,
* this even with .u extension. So check * this even with .u extension. So check
* for non NULL stat->extension * for non NULL stat->extension
*/ */
strncpy(ext, stat->extension, sizeof(ext)); strlcpy(ext, stat->extension, sizeof(ext));
/* HARDLINKCOUNT %u */ /* HARDLINKCOUNT %u */
sscanf(ext, "%13s %u", tag_name, &i_nlink); sscanf(ext, "%13s %u", tag_name, &i_nlink);
if (!strncmp(tag_name, "HARDLINKCOUNT", 13)) if (!strncmp(tag_name, "HARDLINKCOUNT", 13))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册