]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
dd: don’t trust st_size on /proc/files
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 6 Apr 2024 22:15:04 +0000 (15:15 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 6 Apr 2024 22:18:27 +0000 (15:18 -0700)
* src/dd.c (skip): Don’t trust st_size == 0.

src/dd.c

index 370a42c9755538652422019bf3eb293e9fb9b158..6e0d725da57bef6e025ed1118bd99e7276cf369a 100644 (file)
--- a/src/dd.c
+++ b/src/dd.c
@@ -1809,7 +1809,7 @@ skip (int fdesc, char const *file, intmax_t records, idx_t blocksize,
            struct stat st;
            if (ifstat (STDIN_FILENO, &st) != 0)
              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)
              {
                /* When skipping past EOF, return the number of _full_ blocks