[libcxx-commits] [libcxx] [libc++] Fix UB in filesystem::__copy for non-existent destination. (PR #87615)

Afanasyev Ivan via libcxx-commits libcxx-commits at lists.llvm.org
Mon Apr 22 18:59:00 PDT 2024


ivafanas wrote:

It is existing test failure:

```
std/input.output/filesystems/fs.op.funcs/fs.op.copy/copy.pass.cpp
TEST_CASE(from_is_regular_file)
```

Issue depends on `fstat/lstat/stat` posix functions implementation.

At first, I thought, that problem is in linux itself, but documentation states that `struct stat` state is undefined if `fstat/lstat/stat` returned "failure" indicator. So, it happens that bug is in `fs::__copy`. It must not assume that `struct stat` state is saved after `fstat/lstat/stat` call.



https://github.com/llvm/llvm-project/pull/87615


More information about the libcxx-commits mailing list