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

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