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

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