fs: fuse: Fix possible buffer overflow
Ensure that the path in fuse_fs_access_readdir does not overflow the local buffer. Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
parent
14d88c6dc8
commit
3521c95c2f
1 changed files with 8 additions and 2 deletions
|
@ -176,9 +176,15 @@ static int fuse_fs_access_readdir(const char *path, void *buf,
|
|||
* directory but FUSE strips the trailing slashes from
|
||||
* directory names so add it back.
|
||||
*/
|
||||
char mount_path[PATH_MAX];
|
||||
char mount_path[PATH_MAX] = {0};
|
||||
size_t len = strlen(path);
|
||||
|
||||
sprintf(mount_path, "%s/", path);
|
||||
if (len >= (PATH_MAX - 2)) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
memcpy(mount_path, path, len)
|
||||
mount_path[len] = '/';
|
||||
err = fs_opendir(&dir, mount_path);
|
||||
} else {
|
||||
err = fs_opendir(&dir, path);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue