From 4f53b62234eaa24488d45916625d0ada5b8a2a2e Mon Sep 17 00:00:00 2001 From: chenrenhui Date: Fri, 28 Mar 2025 14:27:43 +0800 Subject: [PATCH] config: check for 0 from read When the read returns 0, it could mean the file was trimmed or some other type of problem. In this case abort the potentially endless loop. (cherry picked from commit 071845e9dda29eb7862dba16363711acafb812ca) --- 0036-config-check-for-0-from-read.patch | 30 +++++++++++++++++++++++++ lvm2.spec | 6 ++++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 0036-config-check-for-0-from-read.patch diff --git a/0036-config-check-for-0-from-read.patch b/0036-config-check-for-0-from-read.patch new file mode 100644 index 0000000..79b1d0b --- /dev/null +++ b/0036-config-check-for-0-from-read.patch @@ -0,0 +1,30 @@ +From c3c212d2185c0e185a536f9380e33bccc44f09a4 Mon Sep 17 00:00:00 2001 +From: Zdenek Kabelac +Date: Wed, 29 Jan 2025 00:00:23 +0100 +Subject: [PATCH] config: check for 0 from read + +When the read returns 0, it could mean the file +was trimmed or some other type of problem. +In this case abort the potentially endless loop. + +Reference: https://github.com/lvmteam/lvm2/commit/e907c3cf9a1c294b6551d525d58f3bd7dbbb1cc5 +Conflict: NA +--- + lib/config/config.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/config/config.c b/lib/config/config.c +index 0cb0da1..a4c3fe6 100644 +--- a/lib/config/config.c ++++ b/lib/config/config.c +@@ -534,7 +534,7 @@ int config_file_read_fd(struct dm_config_tree *cft, struct device *dev, dev_io_r + sz = read(dev_fd(dev), buf + rsize, size - rsize); + } while ((sz < 0) && ((errno == EINTR) || (errno == EAGAIN))); + +- if (sz < 0) { ++ if (sz <= 0) { + log_sys_error("read", dev_name(dev)); + goto out; + } +-- +2.33.0 diff --git a/lvm2.spec b/lvm2.spec index 78c13aa..8e2fb2b 100644 --- a/lvm2.spec +++ b/lvm2.spec @@ -43,7 +43,7 @@ Name: lvm2 Version: 2.03.14 -Release: 17 +Release: 18 Epoch: 8 Summary: Tools for logical volume management License: GPLv2+ and LGPLv2.1 and BSD @@ -84,6 +84,7 @@ Patch32: 0032-clean-up-group-struct-in-_stats_create_group-error-path.patch Patch33: 0033-dm-event-release-buffer-on-dm_event_get_version.patch Patch34: 0034-dmstats-Fix-memory-leak-on-error-path.patch Patch35: 0035-fix-function-undeclared-in-libdm-common.c-and-dev-cache.c.patch +Patch36: 0036-config-check-for-0-from-read.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -510,6 +511,9 @@ fi %changelog +* Fri Mar 28 2025 chenrenhui - 8:2.03.14-18 +- config: check for 0 from read + * Mon Nov 18 2024 yanshuai - 8:2.03.14-17 - Avoid unowned %%{python3_sitelib}/lvmdbusd directory -- Gitee