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

This commit is contained in:
Jan Kaluza 2012-01-04 11:11:29 +01:00
parent 87613075c0
commit f7cd9574fb
2 changed files with 51 additions and 1 deletions

View File

@ -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))

View File

@ -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@redhat.com> 3.8.1-3
- fix #736054 - check for missing '{' in config file
* Mon Oct 03 2011 Jan Kaluza <jkaluza@redhat.com> 3.8.1-2
- fix #742731 - man page syntax, formatting, and spelling fixes