提交 27b4923b 编写于 作者: R Rich Felker

make realpath use O_PATH when opening the file

this avoids failure if the file is not readable and avoids odd
behavior for device nodes, etc. on old kernels that lack O_PATH, the
old behavior (O_RDONLY) will naturally happen as the fallback.
上级 9ff8ed46
...@@ -21,7 +21,7 @@ char *realpath(const char *restrict filename, char *restrict resolved) ...@@ -21,7 +21,7 @@ char *realpath(const char *restrict filename, char *restrict resolved)
return 0; return 0;
} }
fd = open(filename, O_RDONLY|O_NONBLOCK|O_CLOEXEC); fd = open(filename, O_PATH|O_NONBLOCK|O_CLOEXEC);
if (fd < 0) return 0; if (fd < 0) return 0;
__procfdname(buf, fd); __procfdname(buf, fd);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册