diff options
Diffstat (limited to 'crypto/heimdal/lib/hdb/db3.c')
-rw-r--r-- | crypto/heimdal/lib/hdb/db3.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/crypto/heimdal/lib/hdb/db3.c b/crypto/heimdal/lib/hdb/db3.c index a682071..92525fc 100644 --- a/crypto/heimdal/lib/hdb/db3.c +++ b/crypto/heimdal/lib/hdb/db3.c @@ -33,9 +33,12 @@ #include "hdb_locl.h" -RCSID("$Id: db3.c,v 1.6 2001/01/30 01:24:00 assar Exp $"); +RCSID("$Id: db3.c,v 1.8 2001/08/09 08:41:48 assar Exp $"); + +#if HAVE_DB3 + +#include <db.h> -#if defined(HAVE_DB_H) && DB_VERSION_MAJOR == 3 static krb5_error_code DB_close(krb5_context context, HDB *db) { @@ -115,8 +118,9 @@ DB_seq(krb5_context context, HDB *db, if (entry->principal == NULL) { entry->principal = malloc(sizeof(*entry->principal)); if (entry->principal == NULL) { - code = ENOMEM; hdb_free_entry (context, entry); + krb5_set_error_string(context, "malloc: out of memory"); + return ENOMEM; } else { hdb_key2principal(context, &key_data, entry->principal); } @@ -252,8 +256,10 @@ DB_open(krb5_context context, HDB *db, int flags, mode_t mode) myflags |= DB_TRUNCATE; asprintf(&fn, "%s.db", db->name); - if (fn == NULL) + if (fn == NULL) { + krb5_set_error_string(context, "malloc: out of memory"); return ENOMEM; + } db_create(&d, NULL, 0); db->db = d; if ((ret = d->open(db->db, fn, NULL, DB_BTREE, myflags, mode))) { @@ -261,14 +267,18 @@ DB_open(krb5_context context, HDB *db, int flags, mode_t mode) /* try to open without .db extension */ if (d->open(db->db, db->name, NULL, DB_BTREE, myflags, mode)) { free(fn); + krb5_set_error_string(context, "opening %s: %s", + db->name, strerror(ret)); return ret; } } free(fn); ret = d->cursor(d, NULL, (DBC **)&db->dbc, 0); - if (ret) + if (ret) { + krb5_set_error_string(context, "d->cursor: %s", strerror(ret)); return ret; + } if((flags & O_ACCMODE) == O_RDONLY) ret = hdb_check_db_format(context, db); @@ -284,11 +294,19 @@ hdb_db_create(krb5_context context, HDB **db, const char *filename) { *db = malloc(sizeof(**db)); - if (*db == NULL) + if (*db == NULL) { + krb5_set_error_string(context, "malloc: out of memory"); return ENOMEM; + } (*db)->db = NULL; (*db)->name = strdup(filename); + if ((*db)->name == NULL) { + krb5_set_error_string(context, "malloc: out of memory"); + free(*db); + *db = NULL; + return ENOMEM; + } (*db)->master_key_set = 0; (*db)->openp = 0; (*db)->open = DB_open; @@ -307,4 +325,4 @@ hdb_db_create(krb5_context context, HDB **db, (*db)->destroy = DB_destroy; return 0; } -#endif +#endif /* HAVE_DB3 */ |