fs: fix dup not compatible with fdcheck & fdsan
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
This commit is contained in:
parent
5b889b9270
commit
2746aa0643
|
@ -55,6 +55,13 @@ int file_dup(FAR struct file *filep, int minfd, int flags)
|
||||||
FAR struct file *filep2;
|
FAR struct file *filep2;
|
||||||
int fd2;
|
int fd2;
|
||||||
int ret;
|
int ret;
|
||||||
|
#ifdef CONFIG_FDSAN
|
||||||
|
uint64_t f_tag_fdsan; /* File owner fdsan tag, init to 0 */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_FDCHECK
|
||||||
|
uint8_t f_tag_fdcheck; /* File owner fdcheck tag, init to 0 */
|
||||||
|
#endif
|
||||||
|
|
||||||
fd2 = file_allocate(g_root_inode, 0, 0, NULL, minfd, true);
|
fd2 = file_allocate(g_root_inode, 0, 0, NULL, minfd, true);
|
||||||
if (fd2 < 0)
|
if (fd2 < 0)
|
||||||
|
@ -63,9 +70,24 @@ int file_dup(FAR struct file *filep, int minfd, int flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = fs_getfilep(fd2, &filep2);
|
ret = fs_getfilep(fd2, &filep2);
|
||||||
|
#ifdef CONFIG_FDSAN
|
||||||
|
f_tag_fdsan = filep2->f_tag_fdsan;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_FDCHECK
|
||||||
|
f_tag_fdcheck = filep2->f_tag_fdcheck;
|
||||||
|
#endif
|
||||||
DEBUGASSERT(ret >= 0);
|
DEBUGASSERT(ret >= 0);
|
||||||
|
|
||||||
ret = file_dup3(filep, filep2, flags);
|
ret = file_dup3(filep, filep2, flags);
|
||||||
|
#ifdef CONFIG_FDSAN
|
||||||
|
filep2->f_tag_fdsan = f_tag_fdsan;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_FDCHECK
|
||||||
|
filep2->f_tag_fdcheck = f_tag_fdcheck;
|
||||||
|
#endif
|
||||||
|
|
||||||
fs_putfilep(filep2);
|
fs_putfilep(filep2);
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue