From 8e6f3f1bfb45a1de9247a3ff5361811a8df8c895 Mon Sep 17 00:00:00 2001 From: Far Date: Tue, 11 Jan 2022 16:03:17 +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: Ic0f8e608363da3ed15e252a3f91c46e8397c245e --- 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 55ddf8cd..6977469d 100644 --- a/syscall/fs_syscall.c +++ b/syscall/fs_syscall.c @@ -118,7 +118,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) {