From 48f652e0e1ff5fc830a5fd8f7f3221945005bc20 Mon Sep 17 00:00:00 2001 From: Olaf Rempel Date: Mon, 23 Mar 2009 17:21:17 +0100 Subject: [PATCH] ntfsclone: fix restore from stdin When doing a ntfclone-restore from stdin and stdin is then closed, ntfsclone will loop forever: $ cat corrupt_image.gz | gzip -d | ntfsclone -r -O somedisk - With this patch the io_all() loop will return an error when the input-stream is closed. --- ntfsprogs/ntfsclone.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ntfsprogs/ntfsclone.c b/ntfsprogs/ntfsclone.c index 58b93c58..a402f9f4 100644 --- a/ntfsprogs/ntfsclone.c +++ b/ntfsprogs/ntfsclone.c @@ -529,6 +529,8 @@ static int io_all(void *fd, void *buf, int count, int do_write) if (i < 0) { if (errno != EAGAIN && errno != EINTR) return -1; + } else if (i == 0 && !do_write && opt.restore_image) { + return -1; } else { count -= i; buf = i + (char *) buf;