dlm_tool: fix missing fclose calls

This commit is contained in:
zouzhimin 2024-04-29 02:24:16 +08:00
parent 58f48f6a60
commit 6827b881e9
2 changed files with 52 additions and 1 deletions

View File

@ -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 <zouzhimin@kylinos.cn> - 4.2.0-7
- dlm_tool: fix missing fclose calls
* Fri Mar 08 2024 zouzhimin <zouzhimin@kylinos.cn> - 4.2.0-6
- build: dlm_controld disable annobin plugin

View File

@ -0,0 +1,47 @@
From e5ca08c20e6f530bfb95db67cbd62e6958f9af26 Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahringo@redhat.com>
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