Blame SOURCES/cryptsetup-2.0.4-fix-write_lseek_blockwise-for-in-the-middle-of-secto.patch

8af939
From 6392be68c4d481148e20dbc2a8380cc246f27ad1 Mon Sep 17 00:00:00 2001
8af939
From: Ondrej Kozina <okozina@redhat.com>
8af939
Date: Tue, 19 Jun 2018 14:45:45 +0200
8af939
Subject: [PATCH 2/4] Fix write_lseek_blockwise for in the middle of sector
8af939
 case.
8af939
8af939
See unit test write_lseek_blockwise(bsize=512, offset=1, length=1).
8af939
8af939
The test tries to modify single byte at offset 1 of device with
8af939
bsize=512.
8af939
---
8af939
 lib/utils_io.c | 4 ++--
8af939
 1 file changed, 2 insertions(+), 2 deletions(-)
8af939
8af939
diff --git a/lib/utils_io.c b/lib/utils_io.c
8af939
index 94c4ef6..8336b18 100644
8af939
--- a/lib/utils_io.c
8af939
+++ b/lib/utils_io.c
8af939
@@ -216,8 +216,8 @@ ssize_t write_lseek_blockwise(int fd, size_t bsize, size_t alignment,
8af939
 		if (lseek(fd, offset - frontHang, SEEK_SET) < 0)
8af939
 			goto out;
8af939
 
8af939
-		r = write_buffer(fd, frontPadBuf, frontHang + innerCount);
8af939
-		if (r < 0 || r != (ssize_t)(frontHang + innerCount))
8af939
+		r = write_buffer(fd, frontPadBuf, bsize);
8af939
+		if (r < 0 || r != (ssize_t)bsize)
8af939
 			goto out;
8af939
 
8af939
 		buf = (char*)buf + innerCount;
8af939
-- 
8af939
1.8.3.1
8af939