From cd4ff514c015e74d8d794edacdac5448d93bab20 Mon Sep 17 00:00:00 2001 From: Mart Jansink Date: Tue, 29 Dec 2020 16:55:09 +0100 Subject: [PATCH] don't call ftruncate() on stdout --- genext2fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/genext2fs.c b/genext2fs.c index 96bbb43..6e8101c 100644 --- a/genext2fs.c +++ b/genext2fs.c @@ -2922,7 +2922,7 @@ copy_file(filesystem *fs, FILE *dst, FILE *src, size_t size) error_msg_and_die("copy_file: out of memory"); if (fseek(src, 0, SEEK_SET)) perror_msg_and_die("fseek"); - if (ftruncate(fileno(dst), 0)) + if ((dst != stdout) && ftruncate(fileno(dst), 0)) perror_msg_and_die("copy_file: ftruncate"); while (size > 0) { if (fread(b, BLOCKSIZE, 1, src) != 1)