Blame SOURCES/cryptsetup-1.7.6-fix-blockwise-access-functions-for-64k-page-size.patch

ef9f96
diff -rupN cryptsetup-1.7.4.bcp/lib/utils.c cryptsetup-1.7.4/lib/utils.c
ef9f96
--- cryptsetup-1.7.4.bcp/lib/utils.c	2017-10-18 11:39:01.694902755 +0200
ef9f96
+++ cryptsetup-1.7.4/lib/utils.c	2017-10-18 11:48:16.584868357 +0200
ef9f96
@@ -252,21 +252,21 @@ ssize_t write_lseek_blockwise(int fd, in
ef9f96
 		if (!frontPadBuf)
ef9f96
 			goto out;
ef9f96
 
ef9f96
-		r = read_buffer(fd, frontPadBuf, bsize);
ef9f96
-		if (r < 0 || r != bsize)
ef9f96
-			goto out;
ef9f96
-
ef9f96
 		innerCount = bsize - frontHang;
ef9f96
 		if (innerCount > count)
ef9f96
 			innerCount = count;
ef9f96
 
ef9f96
+		r = read_buffer(fd, frontPadBuf, bsize);
ef9f96
+		if (r < (frontHang + innerCount))
ef9f96
+			goto out;
ef9f96
+
ef9f96
 		memcpy(frontPadBuf + frontHang, buf, innerCount);
ef9f96
 
ef9f96
 		if (lseek(fd, offset - frontHang, SEEK_SET) < 0)
ef9f96
 			goto out;
ef9f96
 
ef9f96
-		r = write_buffer(fd, frontPadBuf, bsize);
ef9f96
-		if (r < 0 || r != bsize)
ef9f96
+		r = write_buffer(fd, frontPadBuf, frontHang + innerCount);
ef9f96
+		if (r != (frontHang + innerCount))
ef9f96
 			goto out;
ef9f96
 
ef9f96
 		buf = (char*)buf + innerCount;
ef9f96
@@ -311,14 +311,14 @@ ssize_t read_lseek_blockwise(int fd, int
ef9f96
 		if (!frontPadBuf)
ef9f96
 			return ret;
ef9f96
 
ef9f96
-		r = read_buffer(fd, frontPadBuf, bsize);
ef9f96
-		if (r < 0 || r != bsize)
ef9f96
-			goto out;
ef9f96
-
ef9f96
 		innerCount = bsize - frontHang;
ef9f96
 		if (innerCount > count)
ef9f96
 			innerCount = count;
ef9f96
 
ef9f96
+		r = read_buffer(fd, frontPadBuf, bsize);
ef9f96
+		if (r < (frontHang + innerCount))
ef9f96
+			goto out;
ef9f96
+
ef9f96
 		memcpy(buf, frontPadBuf + frontHang, innerCount);
ef9f96
 
ef9f96
 		buf = (char*)buf + innerCount;