From aae8085c618e3b4a994a5316596f031701b0529f Mon Sep 17 00:00:00 2001 From: Matthieu Patou Date: Sun, 15 Apr 2012 14:02:41 -0700 Subject: olschema2ldif: be more strict where checking for open/closed braces --- source4/utils/oLschema2ldif.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'source4/utils/oLschema2ldif.c') diff --git a/source4/utils/oLschema2ldif.c b/source4/utils/oLschema2ldif.c index ae69db19bc..be86daafb7 100644 --- a/source4/utils/oLschema2ldif.c +++ b/source4/utils/oLschema2ldif.c @@ -82,7 +82,12 @@ static int check_braces(const char *string) c = strpbrk(c, "()"); if (c == NULL) return 1; if (*c == '(') b++; - if (*c == ')') b--; + if (*c == ')') { + b--; + if (*(c - 1) != ' ' && c && (*(c + 1) == '\0')) { + return 2; + } + } c++; } return 0; @@ -538,8 +543,10 @@ static struct schema_conv process_file(FILE *in, FILE *out) do { if (c == '\n') { - entry[t] = '\0'; - if (check_braces(entry) == 0) { + int ret2 = 0; + entry[t] = '\0'; + ret2 = check_braces(entry); + if (ret2 == 0) { ret.count++; ldif.msg = process_entry(ctx, entry); if (ldif.msg == NULL) { @@ -550,6 +557,11 @@ static struct schema_conv process_file(FILE *in, FILE *out) ldb_ldif_write_file(ldb_ctx, out, &ldif); break; } + if (ret2 == 2) { + fprintf(stderr, "Invalid entry %s, closing braces needs to be preceeded by a space\n", entry); + ret.failures++; + break; + } line++; } else { entry[t] = c; -- cgit