diff options
| author | Paul Eggert | 2025-01-22 11:06:06 -0800 |
|---|---|---|
| committer | Paul Eggert | 2025-07-13 21:09:38 -0700 |
| commit | ffd65be2277b9a30e77a00ad69c9ba21459f72c5 (patch) | |
| tree | 2a3cc5dc796280ec9cc86e1a374744b0b27169c0 /src/w32dwrite.c | |
| parent | ae30a61c74215c3e02fb3c0d603894457a4cfef5 (diff) | |
| download | emacs-ffd65be2277b9a30e77a00ad69c9ba21459f72c5.tar.gz emacs-ffd65be2277b9a30e77a00ad69c9ba21459f72c5.zip | |
copy-file no longer trusts st_size
In copy-file, do not trust st_size, since it might change as we run,
or we might be in a /proc system where it is unreliable anyway.
Also, fix some other unlikely copy-file bugs while we’re here.
* src/fileio.c (Fcopy_file): Use O_TRUNC when opening a
destination that already exists. This saves us the trouble
of having to call ftruncate with a possibly-bogus st_size;
the old motivation for using ftruncate is no longer compelling.
Do not assume ptrdiff_t is as wide as ssize_t; although this is
true on all known platforms, it’s easy to not assume it.
Don’t trust st_size. Prefer SSIZE_MAX to TYPE_MAXIMUM (ssize_t).
Always read+write, regardless of whether copy_file_range failed.
Diffstat (limited to 'src/w32dwrite.c')
0 files changed, 0 insertions, 0 deletions