From 7d7538d43c360750b6dd13019eb07c914d880bd8 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Mon, 16 Sep 2013 09:00:53 -0700 Subject: [PATCH] Fix error in write_sparse() on incomplete write. Fix a problem where sparse_seek could get left non-zero when we did not finish writing all the data that would take us to that sparse gap. Issue pointed out by David Taylor. --- fileio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fileio.c b/fileio.c index 0e207141..78decee9 100644 --- a/fileio.c +++ b/fileio.c @@ -84,11 +84,14 @@ static int write_sparse(int f, char *buf, int len) while ((ret = write(f, buf + l1, len - (l1+l2))) <= 0) { if (ret < 0 && errno == EINTR) continue; + sparse_seek = 0; return ret; } - if (ret != (int)(len - (l1+l2))) + if (ret != (int)(len - (l1+l2))) { + sparse_seek = 0; return l1+ret; + } return len; } -- 2.47.2