tdb_wrap: prevent tdbs called ".ntdb" or without extensions.
authorRusty Russell <rusty@rustcorp.com.au>
Wed, 20 Feb 2013 04:29:42 +0000 (14:59 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 20 Feb 2013 04:31:19 +0000 (05:31 +0100)
This is another belt-and-braces check in case someone decides to turn
on the fancy new .ntdb extension, and we haven't converted it to ntdb.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/tdb_wrap/tdb_wrap.c

index b96469d7350c72bc0920ad54d4096aa2dbb7903d..0f49be126cb5ade8c69423705d660edab8d1522d 100644 (file)
@@ -23,6 +23,7 @@
 #include "lib/util/dlinklist.h"
 #include "lib/tdb_wrap/tdb_wrap.h"
 #include "lib/param/param.h"
+#include "ccan/str/str.h"
 
 /*
  Log tdb messages via DEBUG().
@@ -145,6 +146,13 @@ struct tdb_wrap *tdb_wrap_open(TALLOC_CTX *mem_ctx,
        struct tdb_wrap *result;
        struct tdb_wrap_private *w;
 
+       /* If they specify a .ntdb extension, but the code hasn't been
+        * converted, we want to complain. */
+       if (name && strends(name, ".ntdb")) {
+               DEBUG(2, ("tdb(%s): This code does not yet understand ntdb.  Please report.\n", name));
+               return NULL;
+       }
+
        result = talloc(mem_ctx, struct tdb_wrap);
        if (result == NULL) {
                return NULL;