dd: don’t trust st_size on /proc/files

* src/dd.c (skip): Don’t trust st_size == 0.
This commit is contained in:
Paul Eggert 2024-04-06 15:15:04 -07:00
parent 225cb8d747
commit ac6b8d8224

View File

@ -1809,7 +1809,7 @@ skip (int fdesc, char const *file, intmax_t records, idx_t blocksize,
struct stat st; struct stat st;
if (ifstat (STDIN_FILENO, &st) != 0) if (ifstat (STDIN_FILENO, &st) != 0)
error (EXIT_FAILURE, errno, _("cannot fstat %s"), quoteaf (file)); error (EXIT_FAILURE, errno, _("cannot fstat %s"), quoteaf (file));
if (usable_st_size (&st) && 0 <= input_offset if (usable_st_size (&st) && 0 < st.st_size && 0 <= input_offset
&& st.st_size - input_offset < offset) && st.st_size - input_offset < offset)
{ {
/* When skipping past EOF, return the number of _full_ blocks /* When skipping past EOF, return the number of _full_ blocks