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

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