Skip to content

Commit

Permalink
fs: fuse: Avoid possible buffer overflow
Browse files Browse the repository at this point in the history
Checks path's size before copying it to local variable.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
(cherry picked from commit 3267bdc)
  • Loading branch information
Flavio Ceolin authored and github-actions[bot] committed Feb 18, 2024
1 parent 4826bc1 commit 9ae5233
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion subsys/fs/fuse_fs_access.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,15 @@ static void release_file_handle(size_t handle)
static bool is_mount_point(const char *path)
{
char dir_path[PATH_MAX];
size_t len;

sprintf(dir_path, "%s", path);
len = strlen(path);
if (len >= sizeof(dir_path)) {
return false;
}

memcpy(dir_path, path, len);
dir_path[len] = '\0';
return strcmp(dirname(dir_path), "/") == 0;
}

Expand Down

0 comments on commit 9ae5233

Please sign in to comment.