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

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