s4:heimdal: import lorikeet-heimdal-200903260854 (commit 8f3b61e3fb466bb9dd457ae88ee0...
[metze/samba/wip.git] / source4 / heimdal / lib / hdb / hdb.c
index ad2c35a43a58a9dbfc68f72979df15a84afc6e22..b533fc5952bd7288ecc9348228ce8b1824fc25ec 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997 - 2007 Kungliga Tekniska Högskolan
+ * Copyright (c) 1997 - 2008 Kungliga Tekniska Högskolan
  * (Royal Institute of Technology, Stockholm, Sweden).
  * All rights reserved.
  *
  * SUCH DAMAGE.
  */
 
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "krb5.h"
 #include "krb5_locl.h"
 #include "hdb_locl.h"
 RCSID("$Id$");
@@ -46,22 +41,24 @@ RCSID("$Id$");
 
 static struct hdb_method methods[] = {
 #if HAVE_DB1 || HAVE_DB3
-    {HDB_INTERFACE_VERSION, "db:",     hdb_db_create},
+    { HDB_INTERFACE_VERSION, "db:",    hdb_db_create},
 #endif
 #if HAVE_NDBM
-    {HDB_INTERFACE_VERSION, "ndbm:",   hdb_ndbm_create},
+    { HDB_INTERFACE_VERSION, "ndbm:",  hdb_ndbm_create},
 #endif
 #if defined(OPENLDAP) && !defined(OPENLDAP_MODULE)
-    {HDB_INTERFACE_VERSION, "ldap:",   hdb_ldap_create},
-    {HDB_INTERFACE_VERSION, "ldapi:",  hdb_ldapi_create},
+    { HDB_INTERFACE_VERSION, "ldap:",  hdb_ldap_create},
+    { HDB_INTERFACE_VERSION, "ldapi:", hdb_ldapi_create},
 #endif
     {0, NULL,  NULL}
 };
 
 #if HAVE_DB1 || HAVE_DB3
-static struct hdb_method dbmetod = {"",        hdb_db_create };
+static struct hdb_method dbmetod =
+    { HDB_INTERFACE_VERSION, "", hdb_db_create };
 #elif defined(HAVE_NDBM)
-static struct hdb_method dbmetod = {"",        hdb_ndbm_create };
+static struct hdb_method dbmetod =
+    { HDB_INTERFACE_VERSION, "", hdb_ndbm_create };
 #endif
 
 
@@ -265,9 +262,10 @@ find_dynamic_method (krb5_context context,
     len = p - filename;
     *rest = filename + len + 1;
 
-    prefix = strndup(filename, len);
+    prefix = malloc(len + 1);
     if (prefix == NULL)
        krb5_errx(context, 1, "out of memory");
+    strlcpy(prefix, filename, len + 1);
 
     if (asprintf(&path, LIBDIR "/hdb_%s.so", prefix) == -1)
        krb5_errx(context, 1, "out of memory");