mirror of
https://github.com/coreutils/coreutils.git
synced 2024-11-23 09:56:42 +08:00
split: don’t trust st_size on /proc files
* src/split.c (create): Don’t trust st_size == 0.
This commit is contained in:
parent
8ff3903281
commit
1116367581
@ -489,10 +489,8 @@ create (char const *name)
|
||||
if (psame_inode (&in_stat_buf, &out_stat_buf))
|
||||
error (EXIT_FAILURE, 0, _("%s would overwrite input; aborting"),
|
||||
quoteaf (name));
|
||||
bool regularish
|
||||
= S_ISREG (out_stat_buf.st_mode) || S_TYPEISSHM (&out_stat_buf);
|
||||
if (! (regularish && out_stat_buf.st_size == 0)
|
||||
&& ftruncate (fd, 0) < 0 && regularish)
|
||||
if (ftruncate (fd, 0) < 0
|
||||
&& (S_ISREG (out_stat_buf.st_mode) || S_TYPEISSHM (&out_stat_buf)))
|
||||
error (EXIT_FAILURE, errno, _("%s: error truncating"), quotef (name));
|
||||
|
||||
return fd;
|
||||
|
Loading…
Reference in New Issue
Block a user