add some more error strings

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@10338 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
2001-07-13 06:30:42 +00:00
parent 398331a46c
commit c7562eda65
7 changed files with 152 additions and 69 deletions

View File

@@ -115,8 +115,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 +253,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 +264,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 +291,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;