logrotate/logrotate-3.8.1-syntax-check.patch

46 lines
1.4 KiB
Diff

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