tdb_wrap: don't let tdb_wrap_open() segfault with name==NULL
authorStefan Metzmacher <metze@samba.org>
Mon, 19 Jan 2015 11:37:13 +0000 (12:37 +0100)
committerMichael Adam <obnox@samba.org>
Mon, 19 Jan 2015 15:17:27 +0000 (16:17 +0100)
Bug: https://bugzilla.samba.org/show_bug.cgi?id=11032

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Mon Jan 19 16:17:28 CET 2015 on sn-devel-104

lib/tdb_wrap/tdb_wrap.c

index e762b334efe89c7d87e00ad0a779d98b9e377d04..62dce062c7c1d552310bb8cbd800ec0931df7e39 100644 (file)
@@ -130,10 +130,16 @@ struct tdb_wrap *tdb_wrap_open(TALLOC_CTX *mem_ctx,
        struct tdb_wrap *result;
        struct tdb_wrap_private *w;
 
+       if (name == NULL) {
+               errno = EINVAL;
+               return NULL;
+       }
+
        /* If they specify a .ntdb extension, but the code hasn't been
         * converted, we want to complain. */
-       if (name && strends(name, ".ntdb")) {
+       if (strends(name, ".ntdb")) {
                DEBUG(2, ("tdb(%s): This code does not yet understand ntdb.  Please report.\n", name));
+               errno = EINVAL;
                return NULL;
        }