Skip to content

Commit d013132

Browse files
Flavio Ceolincfriedt
authored andcommitted
fs: fuse: Avoid possible buffer overflow
Checks path's size before copying it to local variable. Signed-off-by: Flavio Ceolin <[email protected]> (cherry picked from commit 3267bdc)
1 parent 25398f3 commit d013132

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

subsys/fs/fuse_fs_access.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,15 @@ static void release_file_handle(size_t handle)
6565
static bool is_mount_point(const char *path)
6666
{
6767
char dir_path[PATH_MAX];
68+
size_t len;
6869

69-
sprintf(dir_path, "%s", path);
70+
len = strlen(path);
71+
if (len >= sizeof(dir_path)) {
72+
return false;
73+
}
74+
75+
memcpy(dir_path, path, len);
76+
dir_path[len] = '\0';
7077
return strcmp(dirname(dir_path), "/") == 0;
7178
}
7279

0 commit comments

Comments
 (0)