Skip to content

Commit

Permalink
fs: 9p: use strlcpy instead of strncpy
Browse files Browse the repository at this point in the history
For 'NULL' terminated string, recommend always to be ended by zero.

Signed-off-by: Chen Gang <gang.chen@asianux.com>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
  • Loading branch information
Chen Gang authored and Eric Van Hensbergen committed Jul 30, 2013
1 parent ad81f05 commit b3f8ab4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/9p/vfs_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ static umode_t p9mode2unixmode(struct v9fs_session_info *v9ses,
char type = 0, ext[32];
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);
switch (type) {
case 'c':
Expand Down Expand Up @@ -1186,7 +1186,7 @@ v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,
* this even with .u extension. So check
* for non NULL stat->extension
*/
strncpy(ext, stat->extension, sizeof(ext));
strlcpy(ext, stat->extension, sizeof(ext));
/* HARDLINKCOUNT %u */
sscanf(ext, "%13s %u", tag_name, &i_nlink);
if (!strncmp(tag_name, "HARDLINKCOUNT", 13))
Expand Down

0 comments on commit b3f8ab4

Please sign in to comment.