From 3ab9b86b8d7f06d2211cd3d3b1542501603e51e0 Mon Sep 17 00:00:00 2001 From: zouzhimin Date: Mon, 29 Apr 2024 02:24:16 +0800 Subject: [PATCH] dlm_tool: fix missing fclose calls (cherry picked from commit 6827b881e9416f7045d9b65355d55454284523ff) --- dlm.spec | 6 +++- dlm_tool-fix-missing-fclose-calls.patch | 47 +++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 dlm_tool-fix-missing-fclose-calls.patch diff --git a/dlm.spec b/dlm.spec index 7eba224..78e8077 100644 --- a/dlm.spec +++ b/dlm.spec @@ -1,6 +1,6 @@ Name: dlm Version: 4.2.0 -Release: 6 +Release: 7 License: GPLv2 and GPLv2+ and LGPLv2+ Group: System Environment/Kernel Summary: dlm control daemon and tool @@ -18,6 +18,7 @@ Patch0002: fix-various-deadcode-issues.patch Patch0003: update-Linux-kernel-implementations.patch Patch0004: Revert-treewide-add-fcf-protection-full-to-CFLAGS.patch Patch0005: build-dlm_controld-disable-annobin-plugin.patch +Patch0006: dlm_tool-fix-missing-fclose-calls.patch Requires: %{name}-lib = %{version}-%{release} Requires: corosync >= 3.1.0 @@ -101,6 +102,9 @@ install -Dm 0644 init/dlm.sysconfig %{buildroot}/etc/sysconfig/dlm %{_libdir}/pkgconfig/*.pc %changelog +* Mon Apr 29 2024 zouzhimin - 4.2.0-7 +- dlm_tool: fix missing fclose calls + * Fri Mar 08 2024 zouzhimin - 4.2.0-6 - build: dlm_controld disable annobin plugin diff --git a/dlm_tool-fix-missing-fclose-calls.patch b/dlm_tool-fix-missing-fclose-calls.patch new file mode 100644 index 0000000..98c253b --- /dev/null +++ b/dlm_tool-fix-missing-fclose-calls.patch @@ -0,0 +1,47 @@ +From e5ca08c20e6f530bfb95db67cbd62e6958f9af26 Mon Sep 17 00:00:00 2001 +From: Alexander Aring +Date: Thu, 30 Mar 2023 15:21:58 -0400 +Subject: [PATCH] dlm_tool: fix missing fclose calls + +This patch will fix missing fclose() calls when fgets() of do_lockdump() +fails. +--- + dlm_tool/main.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/dlm_tool/main.c b/dlm_tool/main.c +index 52fd5b89..2e6810d6 100644 +--- a/dlm_tool/main.c ++++ b/dlm_tool/main.c +@@ -1177,8 +1177,9 @@ static void do_lockdump(char *name) + } + + /* skip the header on the first line */ +- if (!fgets(line, LOCK_LINE_MAX, file)) +- return; ++ if (!fgets(line, LOCK_LINE_MAX, file)) { ++ goto out; ++ } + + while (fgets(line, LOCK_LINE_MAX, file)) { + rv = sscanf(line, "%x %d %x %u %llu %x %x %hhd %hhd %hhd %u %d %d", +@@ -1199,7 +1200,7 @@ static void do_lockdump(char *name) + if (rv != 13) { + fprintf(stderr, "invalid debugfs line %d: %s\n", + rv, line); +- return; ++ goto out; + } + + memset(r_name, 0, sizeof(r_name)); +@@ -1229,6 +1230,7 @@ static void do_lockdump(char *name) + ownpid, nodeid, r_name); + } + ++ out: + fclose(file); + } + +-- +2.25.1 + -- Gitee