mirror of
https://github.com/apache/nuttx.git
synced 2026-10-07 22:35:22 +00:00
fs/smartfs: mask reserved flags from stat mode.
SMARTFS_DIRENT_RESERVED uses bits that overlap S_ISUID, S_ISGID, and S_ISVTX. smartfs_stat_common() currently clears only S_IFMT, allowing reserved directory-entry flags to appear in st_mode and ls output as setuid and setgid bits. Preserve only SMARTFS_DIRENT_MODE when constructing st_mode. Assisted-by: GPT-5.6 Sol Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
This commit is contained in:
parent
ebabdd57f3
commit
c7cbee7a33
1 changed files with 7 additions and 2 deletions
|
|
@ -1047,10 +1047,12 @@ static int smartfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
case FIOC_FILEPATH:
|
||||
{
|
||||
FAR char *path = (FAR char *)(uintptr_t)arg;
|
||||
|
||||
ret = inode_getpath(inode, path, PATH_MAX);
|
||||
if (ret >= 0)
|
||||
{
|
||||
size_t len = strlen(path);
|
||||
|
||||
if (path[len - 1] != '/')
|
||||
{
|
||||
path[len++] = '/';
|
||||
|
|
@ -2131,9 +2133,12 @@ static void smartfs_stat_common(FAR struct smartfs_mountpt_s *fs,
|
|||
}
|
||||
else
|
||||
{
|
||||
/* Mask out the file type */
|
||||
/* Preserve only the permission bits. The other directory-entry
|
||||
* flags include SMARTFS_DIRENT_RESERVED, which overlaps the POSIX
|
||||
* setuid, setgid, and sticky mode bits.
|
||||
*/
|
||||
|
||||
buf->st_mode = entry->flags & ~S_IFMT;
|
||||
buf->st_mode = entry->flags & SMARTFS_DIRENT_MODE;
|
||||
|
||||
/* Add the file type based on the SmartFS entry flags */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue