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:
27
lib/hdb/db.c
27
lib/hdb/db.c
@@ -110,6 +110,7 @@ DB_seq(krb5_context context, HDB *db,
|
||||
if (code == 0 && entry->principal == NULL) {
|
||||
entry->principal = malloc(sizeof(*entry->principal));
|
||||
if (entry->principal == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
code = ENOMEM;
|
||||
hdb_free_entry (context, entry);
|
||||
} else {
|
||||
@@ -226,21 +227,29 @@ DB_open(krb5_context context, HDB *db, int flags, mode_t mode)
|
||||
krb5_error_code ret;
|
||||
|
||||
asprintf(&fn, "%s.db", db->name);
|
||||
if (fn == NULL)
|
||||
if (fn == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
db->db = dbopen(fn, flags, mode, DB_BTREE, NULL);
|
||||
free(fn);
|
||||
/* try to open without .db extension */
|
||||
if(db->db == NULL && errno == ENOENT)
|
||||
db->db = dbopen(db->name, flags, mode, DB_BTREE, NULL);
|
||||
if(db->db == NULL)
|
||||
return errno;
|
||||
if(db->db == NULL) {
|
||||
ret = errno;
|
||||
krb5_set_error_string(context, "dbopen (%s): %s",
|
||||
db->name, strerror(ret));
|
||||
return ret;
|
||||
}
|
||||
if((flags & O_ACCMODE) == O_RDONLY)
|
||||
ret = hdb_check_db_format(context, db);
|
||||
else
|
||||
ret = hdb_init_db(context, db);
|
||||
if(ret == HDB_ERR_NOENTRY)
|
||||
if(ret == HDB_ERR_NOENTRY) {
|
||||
krb5_clear_error_string(context);
|
||||
return 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -249,11 +258,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;
|
||||
|
Reference in New Issue
Block a user