Fix error in write_sparse() on incomplete write.
authorWayne Davison <wayned@samba.org>
Mon, 16 Sep 2013 16:00:53 +0000 (09:00 -0700)
committerWayne Davison <wayned@samba.org>
Mon, 16 Sep 2013 16:02:46 +0000 (09:02 -0700)
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

index 0e207141eee5c7b868d8b57c2b06b216bd9232d4..78decee90ac5f4d1c1e689950668c7f7df6613e2 100644 (file)
--- 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;
 }