fix FD leak in confparse
This commit is contained in:
parent
c12398419a
commit
b58c84c8bc
@ -1,15 +1,11 @@
|
|||||||
From e2de752020ea51428bbaaa7358f08632c42aa89d Mon Sep 17 00:00:00 2001
|
commit 50c2b3ba8ce030a47b55dd707bb8a6ab20444a05
|
||||||
From: Pavel Zhukov <pzhukov@redhat.com>
|
Author: Pavel Zhukov <pzhukov@redhat.com>
|
||||||
Date: Thu, 21 Feb 2019 10:44:06 +0100
|
Date: Thu Feb 21 10:44:06 2019 +0100
|
||||||
Subject: [PATCH 21/26] Load leases DB in non-replay mode only
|
|
||||||
Cc: pzhukov@redhat.com
|
|
||||||
|
|
||||||
---
|
Load leases DB in non-replay mode only
|
||||||
server/confpars.c | 10 +++++++---
|
|
||||||
1 file changed, 7 insertions(+), 3 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/server/confpars.c b/server/confpars.c
|
diff --git a/server/confpars.c b/server/confpars.c
|
||||||
index 2743979..db21a0b 100644
|
index 2743979..6b61964 100644
|
||||||
--- a/server/confpars.c
|
--- a/server/confpars.c
|
||||||
+++ b/server/confpars.c
|
+++ b/server/confpars.c
|
||||||
@@ -134,6 +134,11 @@ isc_result_t read_conf_file (const char *filename, struct group *group,
|
@@ -134,6 +134,11 @@ isc_result_t read_conf_file (const char *filename, struct group *group,
|
||||||
@ -17,35 +13,38 @@ index 2743979..db21a0b 100644
|
|||||||
cfile = (struct parse *)0;
|
cfile = (struct parse *)0;
|
||||||
#if defined (TRACING)
|
#if defined (TRACING)
|
||||||
+ // No need to dmalloc huge memory region if we're not going to re-play
|
+ // No need to dmalloc huge memory region if we're not going to re-play
|
||||||
+ if (!trace_playback()){
|
+ if (!trace_record()){
|
||||||
+ status = new_parse(&cfile, file, NULL, 0, filename, 0);
|
+ status = new_parse(&cfile, file, NULL, 0, filename, 0);
|
||||||
+ goto noreplay;
|
+ goto noreplay;
|
||||||
+ };
|
+ };
|
||||||
flen = lseek (file, (off_t)0, SEEK_END);
|
flen = lseek (file, (off_t)0, SEEK_END);
|
||||||
if (flen < 0) {
|
if (flen < 0) {
|
||||||
boom:
|
boom:
|
||||||
@@ -171,9 +176,11 @@ isc_result_t read_conf_file (const char *filename, struct group *group,
|
@@ -165,7 +170,6 @@ isc_result_t read_conf_file (const char *filename, struct group *group,
|
||||||
|
if (result != ulen)
|
||||||
|
log_fatal ("%s: short read of %d bytes instead of %d.",
|
||||||
|
filename, ulen, result);
|
||||||
|
- close (file);
|
||||||
|
memfile:
|
||||||
|
/* If we're recording, write out the filename and file contents. */
|
||||||
if (trace_record ())
|
if (trace_record ())
|
||||||
trace_write_packet (ttype, ulen + tflen + 1, dbuf, MDL);
|
@@ -174,6 +178,9 @@ isc_result_t read_conf_file (const char *filename, struct group *group,
|
||||||
status = new_parse(&cfile, -1, fbuf, ulen, filename, 0); /* XXX */
|
|
||||||
+ dfree(dbuf, MDL);
|
|
||||||
#else
|
#else
|
||||||
status = new_parse(&cfile, file, NULL, 0, filename, 0);
|
status = new_parse(&cfile, file, NULL, 0, filename, 0);
|
||||||
#endif
|
#endif
|
||||||
+ noreplay:
|
+ noreplay:
|
||||||
|
+ if (!trace_playback())
|
||||||
|
+ close (file);
|
||||||
if (status != ISC_R_SUCCESS || cfile == NULL)
|
if (status != ISC_R_SUCCESS || cfile == NULL)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
@@ -182,9 +189,6 @@ isc_result_t read_conf_file (const char *filename, struct group *group,
|
@@ -183,7 +190,8 @@ isc_result_t read_conf_file (const char *filename, struct group *group,
|
||||||
else
|
|
||||||
status = conf_file_subparse (cfile, group, group_type);
|
status = conf_file_subparse (cfile, group, group_type);
|
||||||
end_parse (&cfile);
|
end_parse (&cfile);
|
||||||
-#if defined (TRACING)
|
#if defined (TRACING)
|
||||||
- dfree (dbuf, MDL);
|
- dfree (dbuf, MDL);
|
||||||
-#endif
|
+ if (trace_record())
|
||||||
|
+ dfree (dbuf, MDL);
|
||||||
|
#endif
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
--
|
|
||||||
2.14.5
|
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
Summary: Dynamic host configuration protocol software
|
Summary: Dynamic host configuration protocol software
|
||||||
Name: dhcp
|
Name: dhcp
|
||||||
Version: 4.4.1
|
Version: 4.4.1
|
||||||
Release: 19%{?dist}
|
Release: 20%{?dist}
|
||||||
|
|
||||||
# NEVER CHANGE THE EPOCH on this package. The previous maintainer (prior to
|
# NEVER CHANGE THE EPOCH on this package. The previous maintainer (prior to
|
||||||
# dcantrell maintaining the package) made incorrect use of the epoch and
|
# dcantrell maintaining the package) made incorrect use of the epoch and
|
||||||
@ -535,6 +535,9 @@ done
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Nov 27 2019 Pavel Zhukov <pzhukov@redhat.com> - 12:4.4.1-20
|
||||||
|
- Fix leak of file descriptors
|
||||||
|
|
||||||
* Mon Nov 11 2019 Pavel Zhukov <pzhukov@redhat.com> - 12:4.4.1-19
|
* Mon Nov 11 2019 Pavel Zhukov <pzhukov@redhat.com> - 12:4.4.1-19
|
||||||
- Reword -B option description
|
- Reword -B option description
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user