[logrotate] fix #736054 - check for missing '{' in config file

Jan Kaluža jkaluza at fedoraproject.org
Wed Jan 4 10:15:42 UTC 2012


commit f7cd9574fbd851e9213173cfa0191e0f9dd5998c
Author: Jan Kaluza <hanzz.k at gmail.com>
Date:   Wed Jan 4 11:11:29 2012 +0100

    fix #736054 - check for missing '{' in config file

 logrotate-3.8.1-syntax-check.patch |   45 ++++++++++++++++++++++++++++++++++++
 logrotate.spec                     |    7 ++++-
 2 files changed, 51 insertions(+), 1 deletions(-)
---
diff --git a/logrotate-3.8.1-syntax-check.patch b/logrotate-3.8.1-syntax-check.patch
new file mode 100644
index 0000000..0ed3404
--- /dev/null
+++ b/logrotate-3.8.1-syntax-check.patch
@@ -0,0 +1,45 @@
+Index: /trunk/config.c
+===================================================================
+--- trunk/config.c	(revision 343)
++++ trunk/config.c	(revision 344)
+@@ -600,4 +600,5 @@
+ 	static unsigned recursion_depth = 0U;
+ 	char *globerr_msg = NULL;
++	int in_config = 0;
+ 	struct flock fd_lock = {
+ 		.l_start = 0,
+@@ -1301,4 +1302,5 @@
+ 				key = NULL;
+ 			} else if (*start == '/' || *start == '"' || *start == '\'') {
++				in_config = 0;
+ 				if (newlog != defConfig) {
+ 					message(MESS_ERROR, "%s:%d unexpected log filename\n",
+@@ -1323,8 +1325,16 @@
+ 
+ 				endtag = start;
+-				while (endtag - buf < length && *endtag != '{' && *endtag != '\0') {
++				while (endtag - buf < length && *endtag != '{' && *endtag != '}' && *endtag != '\0') {
+ 					endtag++;}
+ 				if (endtag - buf > length)
+ 					continue;
++				if (*endtag == '}') {
++					message(MESS_ERROR, "%s:%d unexpected } (missing previous '{')\n", configFile,
++						lineNum);
++					goto error;
++				}
++				if (*endtag == '{') {
++					in_config = 1;
++				}
+ 				char *key = strndup(start, endtag - start);
+ 				start = endtag;
+@@ -1418,4 +1428,10 @@
+ 					goto error;
+ 				}
++				if (!in_config) {
++					message(MESS_ERROR, "%s:%d unexpected } (missing previous '{')\n", configFile,
++						lineNum);
++					goto error;
++				}
++				in_config = 0;
+ 			if (globerr_msg) {
+ 				if (!(newlog->flags & LOG_FLAG_MISSINGOK))
diff --git a/logrotate.spec b/logrotate.spec
index 40032aa..fddfe68 100644
--- a/logrotate.spec
+++ b/logrotate.spec
@@ -1,12 +1,13 @@
 Summary: Rotates, compresses, removes and mails system log files
 Name: logrotate
 Version: 3.8.1
-Release: 2%{?dist}
+Release: 3%{?dist}
 License: GPL+
 Group: System Environment/Base
 Url: https://fedorahosted.org/logrotate/
 Source: https://fedorahosted.org/releases/l/o/logrotate/logrotate-%{version}.tar.gz
 Patch1: logrotate-3.8.1-man.patch
+Patch2: logrotate-3.8.1-syntax-check.patch
 
 Requires: coreutils >= 5.92 libsepol libselinux popt libacl
 BuildRequires: libselinux-devel popt-devel libacl-devel
@@ -26,6 +27,7 @@ log files on your system.
 %prep
 %setup -q
 %patch1 -b .man
+%patch2 -p1 -b .syntax-check
 
 %build
 make %{?_smp_mflags} RPM_OPT_FLAGS="$RPM_OPT_FLAGS" WITH_SELINUX=yes WITH_ACL=yes
@@ -56,6 +58,9 @@ rm -rf $RPM_BUILD_ROOT
 %attr(0644, root, root) %verify(not size md5 mtime) %config(noreplace) %{_localstatedir}/lib/logrotate.status
 
 %changelog
+* Wed Jan 04 2012 Jan Kaluza <jkaluza at redhat.com> 3.8.1-3
+- fix #736054 - check for missing '{' in config file
+
 * Mon Oct 03 2011 Jan Kaluza <jkaluza at redhat.com> 3.8.1-2
 - fix #742731 - man page syntax, formatting, and spelling fixes
 


More information about the scm-commits mailing list