[logrotate/f14] fix #718549 - fixed crash when opening empty config files

Jan Kaluža jkaluza at fedoraproject.org
Wed Jul 20 07:51:51 UTC 2011


commit a4e4cd399c09faf7981da5e9bac53332318f4415
Author: Jan Kaluza <hanzz.k at gmail.com>
Date:   Wed Jul 20 09:50:48 2011 +0200

    fix #718549 - fixed crash when opening empty config files

 logrotate-3.7.9-empty-config.patch |   20 ++++++++++++++++++++
 logrotate.spec                     |    7 ++++++-
 2 files changed, 26 insertions(+), 1 deletions(-)
---
diff --git a/logrotate-3.7.9-empty-config.patch b/logrotate-3.7.9-empty-config.patch
new file mode 100644
index 0000000..46fe98b
--- /dev/null
+++ b/logrotate-3.7.9-empty-config.patch
@@ -0,0 +1,20 @@
+diff --git a/config.c b/config.c
+index e6d5d1d..9498b0b 100644
+--- a/config.c
++++ b/config.c
+@@ -546,6 +546,15 @@ static int readConfigFile(const char *configFile, struct logInfo *defConfig)
+     }
+ 
+ 	length = sb.st_size;
++	/* We can't mmap empty file... */
++	if (length == 0) {
++		message(MESS_DEBUG,
++			"Ignoring %s because it's empty.\n",
++			configFile);
++		close(fd);
++		return 0;
++	}
++	
+ 	buf = mmap(NULL, (size_t)(length + 2), PROT_READ | PROT_WRITE,
+ 			MAP_PRIVATE | MAP_POPULATE, fd, (off_t) 0);
+ 	if (buf == MAP_FAILED) {
diff --git a/logrotate.spec b/logrotate.spec
index f19655a..136ae65 100644
--- a/logrotate.spec
+++ b/logrotate.spec
@@ -1,7 +1,7 @@
 Summary: Rotates, compresses, removes and mails system log files
 Name: logrotate
 Version: 3.7.9
-Release: 3%{?dist}
+Release: 4%{?dist}
 License: GPL+
 Group: System Environment/Base
 Url: https://fedorahosted.org/logrotate/
@@ -10,6 +10,7 @@ Source: https://fedorahosted.org/releases/l/o/logrotate/logrotate-%{version}.tar
 Patch1: logrotate-3.7.9-shred.patch
 Patch2: logrotate-3.7.9-statefile.patch
 Patch3: logrotate-3.7.9-atomic-create.patch
+Patch4: logrotate-3.7.9-empty-config.patch
 
 Requires: coreutils >= 5.92 libsepol libselinux popt
 BuildRequires: libselinux-devel popt-devel
@@ -32,6 +33,7 @@ log files on your system.
 %patch1
 %patch2
 %patch3 -p1
+%patch4 -p1
 
 %build
 make %{?_smp_mflags} RPM_OPT_FLAGS="$RPM_OPT_FLAGS" WITH_SELINUX=yes
@@ -62,6 +64,9 @@ rm -rf $RPM_BUILD_ROOT
 %attr(0644, root, root) %verify(not size md5 mtime) %config(noreplace) %{_localstatedir}/lib/logrotate.status
 
 %changelog
+* Wed Jul 20 2011 Jan Kaluza <jkaluza at redhat.com> 3.7.9-4
+- fix #718549 - fixed crash when opening empty config files
+
 * Mon Mar 28 2011 Jan Kaluza <jkaluza at redhat.com> 3.7.9-3
 - fix #689061 - added Url
 


More information about the scm-commits mailing list