fix potential file descriptor leak in patch file
This commit is contained in:
parent
fb70bdbdad
commit
db861516a2
@ -7,11 +7,11 @@ reason: rsyslog-8.24.0, set permission of syslogd dot pid to 0644
|
|||||||
|
|
||||||
Signed-off-by: guoxiaoqi <guoxiaoqi2@huawei.com>
|
Signed-off-by: guoxiaoqi <guoxiaoqi2@huawei.com>
|
||||||
---
|
---
|
||||||
tools/rsyslogd.c | 5 ++++-
|
tools/rsyslogd.c | 9 ++++++++-
|
||||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
1 file changed, 8 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
diff --git a/tools/rsyslogd.c b/tools/rsyslogd.c
|
diff --git a/tools/rsyslogd.c b/tools/rsyslogd.c
|
||||||
index ccc114b..1f1328e 100644
|
index d2e4833..834fc08 100644
|
||||||
--- a/tools/rsyslogd.c
|
--- a/tools/rsyslogd.c
|
||||||
+++ b/tools/rsyslogd.c
|
+++ b/tools/rsyslogd.c
|
||||||
@@ -28,6 +28,7 @@
|
@@ -28,6 +28,7 @@
|
||||||
@ -30,15 +30,23 @@ index ccc114b..1f1328e 100644
|
|||||||
DEFiRet;
|
DEFiRet;
|
||||||
|
|
||||||
const char *tmpPidFile;
|
const char *tmpPidFile;
|
||||||
@@ -278,7 +280,8 @@ writePidFile(void)
|
@@ -278,10 +280,15 @@ writePidFile(void)
|
||||||
if(tmpPidFile == NULL)
|
if(tmpPidFile == NULL)
|
||||||
tmpPidFile = PidFile;
|
tmpPidFile = PidFile;
|
||||||
DBGPRINTF("rsyslogd: writing pidfile '%s'.\n", tmpPidFile);
|
DBGPRINTF("rsyslogd: writing pidfile '%s'.\n", tmpPidFile);
|
||||||
- if((fp = fopen((char*) tmpPidFile, "w")) == NULL) {
|
- if((fp = fopen((char*) tmpPidFile, "w")) == NULL) {
|
||||||
+ if ( ((fd = open(tmpPidFile, O_WRONLY|O_CREAT|O_CLOEXEC, 0644)) == -1)
|
+ if ( (fd = open(tmpPidFile, O_WRONLY|O_CREAT|O_CLOEXEC, 0644)) == -1) {
|
||||||
+ || ((fp = fdopen(fd, "w")) == NULL) ) {
|
|
||||||
perror("rsyslogd: error writing pid file (creation stage)\n");
|
perror("rsyslogd: error writing pid file (creation stage)\n");
|
||||||
ABORT_FINALIZE(RS_RET_ERR);
|
ABORT_FINALIZE(RS_RET_ERR);
|
||||||
}
|
}
|
||||||
|
+ if ((fp = fdopen(fd, "w")) == NULL) {
|
||||||
|
+ close(fd);
|
||||||
|
+ perror("rsyslogd: error writing pid file (fp binding stage)\n");
|
||||||
|
+ ABORT_FINALIZE(RS_RET_ERR);
|
||||||
|
+ }
|
||||||
|
if(fprintf(fp, "%d", (int) glblGetOurPid()) < 0) {
|
||||||
|
LogError(errno, iRet, "rsyslog: error writing pid file");
|
||||||
|
}
|
||||||
--
|
--
|
||||||
2.19.1
|
1.8.3.1
|
||||||
|
|
||||||
10
rsyslog.spec
10
rsyslog.spec
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Name: rsyslog
|
Name: rsyslog
|
||||||
Version: 8.2006.0
|
Version: 8.2006.0
|
||||||
Release: 1
|
Release: 2
|
||||||
Summary: The rocket-fast system for log processing
|
Summary: The rocket-fast system for log processing
|
||||||
License: (GPLv3+ and ASL 2.0)
|
License: (GPLv3+ and ASL 2.0)
|
||||||
URL: http://www.rsyslog.com/
|
URL: http://www.rsyslog.com/
|
||||||
@ -20,7 +20,7 @@ Source7: timezone.cron
|
|||||||
Patch9000: rsyslog-8.24.0-ensure-parent-dir-exists-when-writting-log-file.patch
|
Patch9000: rsyslog-8.24.0-ensure-parent-dir-exists-when-writting-log-file.patch
|
||||||
Patch9001: bugfix-rsyslog-7.4.7-imjournal-add-monotonic-timestamp.patch
|
Patch9001: bugfix-rsyslog-7.4.7-imjournal-add-monotonic-timestamp.patch
|
||||||
Patch9002: bugfix-rsyslog-7.4.7-add-configuration-to-avoid-memory-leak.patch
|
Patch9002: bugfix-rsyslog-7.4.7-add-configuration-to-avoid-memory-leak.patch
|
||||||
Patch9003: uvp-security-rsyslog-8.24.0-set-permission-of-syslogd-dot-pid-to-0644.patch
|
Patch9003: rsyslog-8.24.0-set-permission-of-syslogd-dot-pid-to-0644.patch
|
||||||
Patch9004: rsyslog-8.37.0-initialize-variables-and-check-return-value.patch
|
Patch9004: rsyslog-8.37.0-initialize-variables-and-check-return-value.patch
|
||||||
|
|
||||||
BuildRequires: gcc autoconf automake bison dos2unix flex pkgconfig python3-docutils libtool
|
BuildRequires: gcc autoconf automake bison dos2unix flex pkgconfig python3-docutils libtool
|
||||||
@ -359,6 +359,12 @@ done
|
|||||||
%{_mandir}/man1/rscryutil.1.gz
|
%{_mandir}/man1/rscryutil.1.gz
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Sep 15 2020 Guodong Zhu<zhuguodong8@huawei.com> - 8.2006.0-2
|
||||||
|
- Type:NA
|
||||||
|
- ID:NA
|
||||||
|
- SUG:restart
|
||||||
|
- DESC: fix potential file descriptor leak in one backport patch
|
||||||
|
|
||||||
* Mon Jul 27 2020 shixuantong<shixuantong@huawei.com> - 8.2006.0-1
|
* Mon Jul 27 2020 shixuantong<shixuantong@huawei.com> - 8.2006.0-1
|
||||||
- Type:NA
|
- Type:NA
|
||||||
- ID:NA
|
- ID:NA
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user