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

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