From b50ebc3228c9b4eacbccaf1ec4572c3ee7b07e1c Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Wed, 2 Mar 2011 22:40:13 +0100 Subject: ldb:ldb tools - return LDB_ERR_INVALID_DN_SYNTAX on wrong DN parameters Not all LDB databases have further DN checks. Reviewed by: Tridge --- source4/lib/ldb/tools/ldbdel.c | 2 +- source4/lib/ldb/tools/ldbedit.c | 2 +- source4/lib/ldb/tools/ldbrename.c | 4 ++++ source4/lib/ldb/tools/ldbsearch.c | 2 +- source4/lib/ldb/tools/ldbtest.c | 4 ++-- 5 files changed, 9 insertions(+), 5 deletions(-) (limited to 'source4') diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index d374fa96e3..270cb83b53 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -113,7 +113,7 @@ int main(int argc, const char **argv) dn = ldb_dn_new(ldb, ldb, options->argv[i]); if ( ! ldb_dn_validate(dn)) { printf("Invalid DN format\n"); - return LDB_ERR_OPERATIONS_ERROR; + return LDB_ERR_INVALID_DN_SYNTAX; } if (options->recursive) { ret = ldb_delete_recursive(ldb, dn,req_ctrls); diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c index 6509263a58..8df37060c6 100644 --- a/source4/lib/ldb/tools/ldbedit.c +++ b/source4/lib/ldb/tools/ldbedit.c @@ -328,7 +328,7 @@ int main(int argc, const char **argv) basedn = ldb_dn_new(ldb, ldb, options->basedn); if ( ! ldb_dn_validate(basedn)) { printf("Invalid Base DN format\n"); - return LDB_ERR_OPERATIONS_ERROR; + return LDB_ERR_INVALID_DN_SYNTAX; } } diff --git a/source4/lib/ldb/tools/ldbrename.c b/source4/lib/ldb/tools/ldbrename.c index 0a539cc651..e8f67500fc 100644 --- a/source4/lib/ldb/tools/ldbrename.c +++ b/source4/lib/ldb/tools/ldbrename.c @@ -66,6 +66,10 @@ int main(int argc, const char **argv) dn1 = ldb_dn_new(ldb, ldb, options->argv[0]); dn2 = ldb_dn_new(ldb, ldb, options->argv[1]); + if ((!ldb_dn_validate(dn1)) || (!ldb_dn_validate(dn2))) { + printf("Invalid DN format(s)\n"); + return LDB_ERR_INVALID_DN_SYNTAX; + } ret = ldb_rename(ldb, dn1, dn2); if (ret == LDB_SUCCESS) { diff --git a/source4/lib/ldb/tools/ldbsearch.c b/source4/lib/ldb/tools/ldbsearch.c index 398710c658..8c101719a3 100644 --- a/source4/lib/ldb/tools/ldbsearch.c +++ b/source4/lib/ldb/tools/ldbsearch.c @@ -299,7 +299,7 @@ int main(int argc, const char **argv) basedn = ldb_dn_new(ldb, ldb, options->basedn); if ( ! ldb_dn_validate(basedn)) { fprintf(stderr, "Invalid Base DN format\n"); - return LDB_ERR_OPERATIONS_ERROR; + return LDB_ERR_INVALID_DN_SYNTAX; } } diff --git a/source4/lib/ldb/tools/ldbtest.c b/source4/lib/ldb/tools/ldbtest.c index 15c1e8b61e..a9d8fafe81 100644 --- a/source4/lib/ldb/tools/ldbtest.c +++ b/source4/lib/ldb/tools/ldbtest.c @@ -264,8 +264,8 @@ static void start_test(struct ldb_context *ldb, unsigned int nrecords, basedn = ldb_dn_new(ldb, ldb, options->basedn); if ( ! ldb_dn_validate(basedn)) { - printf("Invalid base DN\n"); - exit(LDB_ERR_OPERATIONS_ERROR); + printf("Invalid base DN format\n"); + exit(LDB_ERR_INVALID_DN_SYNTAX); } printf("Adding %d records\n", nrecords); -- cgit