From: Matthieu Patou Date: Sun, 15 Apr 2012 21:02:41 +0000 (-0700) Subject: olschema2ldif: be more strict where checking for open/closed braces X-Git-Tag: samba-4.0.0alpha21~335 X-Git-Url: http://git.samba.org/?p=samba.git;a=commitdiff_plain;h=aae8085c618e3b4a994a5316596f031701b0529f olschema2ldif: be more strict where checking for open/closed braces --- diff --git a/source4/utils/oLschema2ldif.c b/source4/utils/oLschema2ldif.c index ae69db19bc3..be86daafb71 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;