Blame SOURCES/cryptsetup-2.0.4-zero-length-lseek-blockwise-i-o-should-return-zero.patch

7cdc99
From 685bcc56351b3e46b69d46118d23268b69052097 Mon Sep 17 00:00:00 2001
7cdc99
From: Ondrej Kozina <okozina@redhat.com>
7cdc99
Date: Tue, 19 Jun 2018 14:07:20 +0200
7cdc99
Subject: [PATCH 1/4] Zero length lseek blockwise i/o should return zero.
7cdc99
7cdc99
Note that both functions perform seek operations aligned to sector
7cdc99
boundary if possible before returning.
7cdc99
7cdc99
Unaligned input offset gets aligned on first preceding sector
7cdc99
boundary.
7cdc99
---
7cdc99
 lib/utils_io.c | 4 ++--
7cdc99
 1 file changed, 2 insertions(+), 2 deletions(-)
7cdc99
7cdc99
diff --git a/lib/utils_io.c b/lib/utils_io.c
7cdc99
index 0f671d6..94c4ef6 100644
7cdc99
--- a/lib/utils_io.c
7cdc99
+++ b/lib/utils_io.c
7cdc99
@@ -199,7 +199,7 @@ ssize_t write_lseek_blockwise(int fd, size_t bsize, size_t alignment,
7cdc99
 	if (lseek(fd, offset - frontHang, SEEK_SET) < 0)
7cdc99
 		return -1;
7cdc99
 
7cdc99
-	if (frontHang) {
7cdc99
+	if (frontHang && length) {
7cdc99
 		if (posix_memalign(&frontPadBuf, alignment, bsize))
7cdc99
 			return -1;
7cdc99
 
7cdc99
@@ -253,7 +253,7 @@ ssize_t read_lseek_blockwise(int fd, size_t bsize, size_t alignment,
7cdc99
 	if (lseek(fd, offset - frontHang, SEEK_SET) < 0)
7cdc99
 		return -1;
7cdc99
 
7cdc99
-	if (frontHang) {
7cdc99
+	if (frontHang && length) {
7cdc99
 		if (posix_memalign(&frontPadBuf, alignment, bsize))
7cdc99
 			return -1;
7cdc99
 
7cdc99
-- 
7cdc99
1.8.3.1
7cdc99