lib_fdopendir.c:Fix crash in fdopendir caused by fdsan

Summary:
  Add fdsan check in fdopendir, fdsan can work normally when using fdopendir

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
This commit is contained in:
chenrun1 2024-09-20 17:36:43 +08:00 committed by archer
parent ba5091d2f7
commit 2e8e37bbf8
1 changed files with 11 additions and 0 deletions

View File

@ -27,6 +27,10 @@
#include <dirent.h>
#include <errno.h>
#ifdef CONFIG_FDSAN
# include <android/fdsan.h>
#endif
#include "libc.h"
/****************************************************************************
@ -83,5 +87,12 @@ FAR DIR *fdopendir(int fd)
}
dir->fd = fd;
#ifdef CONFIG_FDSAN
android_fdsan_exchange_owner_tag(fd, 0,
android_fdsan_create_owner_tag(ANDROID_FDSAN_OWNER_TYPE_DIR,
(uintptr_t)dir));
#endif
return dir;
}