From f2861ddfb424af7b99c278273601ce0fab1f37e6 Mon Sep 17 00:00:00 2001 From: Far Date: Tue, 11 Jan 2022 14:47:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dfutime=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E9=94=99=E8=AF=AF22=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 调用futime时,系统调用接口函数直接使用了file结构体的f_path字段,该字段在退出前被错误地释放了。 避免该问题需要拷贝一份路径 Signed-off-by: Far Change-Id: I519ccb38bec323c93aa8cff920143bb3f9931c22 --- syscall/fs_syscall.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/syscall/fs_syscall.c b/syscall/fs_syscall.c index da90e293..99cd5213 100755 --- a/syscall/fs_syscall.c +++ b/syscall/fs_syscall.c @@ -119,7 +119,10 @@ static int GetFullpathNull(int fd, const char *path, char **filePath) if (ret < 0) { return -get_errno(); } - fullPath = file->f_path; + fullPath = strdup(file->f_path); + if (fullPath == NULL) { + ret = -ENOMEM; + } } else { ret = GetFullpath(fd, path, &fullPath); if (ret < 0) {