diff options
author | Dominique Martinet <asmadeus@codewreck.org> | 2021-11-02 22:24:22 +0900 |
---|---|---|
committer | Dominique Martinet <asmadeus@codewreck.org> | 2021-11-03 17:45:04 +0900 |
commit | 05f975cd6a0b35a0fba725250c7b7cdb680046fa (patch) | |
tree | f17228e752e0d18f9ad8a894560266cb20cb7b31 /fs/9p | |
parent | 10c69a0d08bb2ad5bf17ef85a27362783ffb893a (diff) |
9p p9mode2perm: remove useless strlcpy and check sscanf return code
This is also a checkpatch warning fix but this one might have implications
so keeping it separate
Link: http://lkml.kernel.org/r/20211102134608.1588018-5-dominique.martinet@atmark-techno.com
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
Diffstat (limited to 'fs/9p')
-rw-r--r-- | fs/9p/vfs_inode.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 441f62d22064..d50e19c782cd 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -108,7 +108,7 @@ static int p9mode2perm(struct v9fs_session_info *v9ses, static umode_t p9mode2unixmode(struct v9fs_session_info *v9ses, struct p9_wstat *stat, dev_t *rdev) { - int res; + int res, r; u32 mode = stat->mode; *rdev = 0; @@ -126,11 +126,16 @@ static umode_t p9mode2unixmode(struct v9fs_session_info *v9ses, res |= S_IFIFO; else if ((mode & P9_DMDEVICE) && (v9fs_proto_dotu(v9ses)) && (v9ses->nodev == 0)) { - char type = 0, ext[32]; + char type = 0; int major = -1, minor = -1; - strlcpy(ext, stat->extension, sizeof(ext)); - sscanf(ext, "%c %i %i", &type, &major, &minor); + r = sscanf(stat->extension, "%c %i %i", &type, &major, &minor); + if (r != 3) { + p9_debug(P9_DEBUG_ERROR, + "invalid device string, umode will be bogus: %s\n", + stat->extension); + return res; + } switch (type) { case 'c': res |= S_IFCHR; |