coreutils/backport-dd-don-t-trust-st_size-on-proc-files.patch

31 lines
1.1 KiB
Diff
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From ac6b8d8224de140f5a6f2ca66e6ce279604a37e6 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sat, 6 Apr 2024 15:15:04 -0700
Subject: [PATCH] =?UTF-8?q?dd:=20don=E2=80=99t=20trust=20st=5Fsize=20on=20?=
=?UTF-8?q?/proc/files?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* src/dd.c (skip): Dont trust st_size == 0
---
src/dd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/dd.c b/src/dd.c
index b50b841..a582111 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -1813,7 +1813,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
--
2.27.0