hdparm: fix fd leak in sysfs_write_attr()
In sysfs_write_attr(), if "fmt[0] != %", will return without close fp. Fix issue: https://gitee.com/src-openeuler/hdparm/issues/I4S2C0 Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
This commit is contained in:
parent
5614c4a6fb
commit
4bf23f4238
33
0003-hdparm-fix-fd-leak-in-sysfs_write_attr.patch
Normal file
33
0003-hdparm-fix-fd-leak-in-sysfs_write_attr.patch
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
From ac3b725928b6b6c4a1188670a67ed5432744de26 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
|
||||||
|
Date: Tue, 1 Mar 2022 15:47:02 +0800
|
||||||
|
Subject: [PATCH] hdparm: fix fd leak in sysfs_write_attr()
|
||||||
|
|
||||||
|
In sysfs_write_attr(), if "fmt[0] != %", will return without
|
||||||
|
close fp.
|
||||||
|
|
||||||
|
Fix issue: https://gitee.com/src-openeuler/hdparm/issues/I4S2C0
|
||||||
|
|
||||||
|
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
|
||||||
|
---
|
||||||
|
sysfs.c | 3 ++-
|
||||||
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/sysfs.c b/sysfs.c
|
||||||
|
index 60b8146..722b2a9 100644
|
||||||
|
--- a/sysfs.c
|
||||||
|
+++ b/sysfs.c
|
||||||
|
@@ -60,8 +60,9 @@ static int sysfs_write_attr (char *path, const char *attr, const char *fmt, void
|
||||||
|
}
|
||||||
|
if (count < 0)
|
||||||
|
err = errno;
|
||||||
|
- fclose(fp);
|
||||||
|
}
|
||||||
|
+ if (!fp)
|
||||||
|
+ fclose(fp);
|
||||||
|
if (err && verbose) perror(path);
|
||||||
|
*pathtail = '\0';
|
||||||
|
return err;
|
||||||
|
--
|
||||||
|
1.8.3.1
|
||||||
|
|
||||||
@ -1,12 +1,13 @@
|
|||||||
Name: hdparm
|
Name: hdparm
|
||||||
Version: 9.62
|
Version: 9.62
|
||||||
Release: 2
|
Release: 3
|
||||||
Summary: A system utility for setting or showing hard drive parameters
|
Summary: A system utility for setting or showing hard drive parameters
|
||||||
License: BSD
|
License: BSD
|
||||||
URL: https://sourceforge.net/projects/%{name}/
|
URL: https://sourceforge.net/projects/%{name}/
|
||||||
Source0: https://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz
|
Source0: https://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz
|
||||||
Patch1: 0001-hdparm-fallocate-close-fd.patch
|
Patch1: 0001-hdparm-fallocate-close-fd.patch
|
||||||
Patch2: 0002-hdparam-Remove-security_password-printing.patch
|
Patch2: 0002-hdparam-Remove-security_password-printing.patch
|
||||||
|
Patch3: 0003-hdparm-fix-fd-leak-in-sysfs_write_attr.patch
|
||||||
|
|
||||||
BuildRequires: gcc
|
BuildRequires: gcc
|
||||||
|
|
||||||
@ -43,6 +44,9 @@ install -c -m 644 hdparm.8 $RPM_BUILD_ROOT/%{_mandir}/man8
|
|||||||
%{_mandir}/man8/hdparm.8*
|
%{_mandir}/man8/hdparm.8*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Mar 01 2022 Zhiqiang Liu <liuzhiqiang26@huawei.com> 9.62-3
|
||||||
|
- fix fd leak in sysfs_write_attr()
|
||||||
|
|
||||||
* Sat Jan 22 2022 volcanodragon <linfeilong@huawei.com> 9.62-2
|
* Sat Jan 22 2022 volcanodragon <linfeilong@huawei.com> 9.62-2
|
||||||
- delete passwd print for security
|
- delete passwd print for security
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user