Skip to content

Commit 05f975c

Browse files
committed
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/[email protected] Signed-off-by: Dominique Martinet <[email protected]>
1 parent 10c69a0 commit 05f975c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

fs/9p/vfs_inode.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static int p9mode2perm(struct v9fs_session_info *v9ses,
108108
static umode_t p9mode2unixmode(struct v9fs_session_info *v9ses,
109109
struct p9_wstat *stat, dev_t *rdev)
110110
{
111-
int res;
111+
int res, r;
112112
u32 mode = stat->mode;
113113

114114
*rdev = 0;
@@ -126,11 +126,16 @@ static umode_t p9mode2unixmode(struct v9fs_session_info *v9ses,
126126
res |= S_IFIFO;
127127
else if ((mode & P9_DMDEVICE) && (v9fs_proto_dotu(v9ses))
128128
&& (v9ses->nodev == 0)) {
129-
char type = 0, ext[32];
129+
char type = 0;
130130
int major = -1, minor = -1;
131131

132-
strlcpy(ext, stat->extension, sizeof(ext));
133-
sscanf(ext, "%c %i %i", &type, &major, &minor);
132+
r = sscanf(stat->extension, "%c %i %i", &type, &major, &minor);
133+
if (r != 3) {
134+
p9_debug(P9_DEBUG_ERROR,
135+
"invalid device string, umode will be bogus: %s\n",
136+
stat->extension);
137+
return res;
138+
}
134139
switch (type) {
135140
case 'c':
136141
res |= S_IFCHR;

0 commit comments

Comments
 (0)