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

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