Round #2 of scan-build warnings cleanup

This commit is contained in:
Nicolas Williams
2016-11-16 11:39:27 -06:00
parent 953dc07391
commit 1c81ddf4e2
39 changed files with 136 additions and 104 deletions

View File

@@ -222,9 +222,11 @@ hdb_remove_aliases(krb5_context context, HDB *db, krb5_data *key)
for (i = 0; i < aliases->aliases.len; i++) {
krb5_data akey;
hdb_principal2key(context, &aliases->aliases.val[i], &akey);
code = db->hdb__del(context, db, akey);
krb5_data_free(&akey);
code = hdb_principal2key(context, &aliases->aliases.val[i], &akey);
if (code == 0) {
code = db->hdb__del(context, db, akey);
krb5_data_free(&akey);
}
if (code) {
free_hdb_entry(&oldentry);
return code;
@@ -251,14 +253,16 @@ hdb_add_aliases(krb5_context context, HDB *db,
hdb_entry_alias entryalias;
entryalias.principal = entry->entry.principal;
hdb_principal2key(context, &aliases->aliases.val[i], &key);
code = hdb_entry_alias2value(context, &entryalias, &value);
if (code) {
krb5_data_free(&key);
return code;
}
code = db->hdb__put(context, db, flags, key, value);
krb5_data_free(&key);
code = hdb_principal2key(context, &aliases->aliases.val[i], &key);
if (code == 0) {
code = db->hdb__put(context, db, flags, key, value);
krb5_data_free(&key);
}
krb5_data_free(&value);
if (code)
return code;
@@ -283,9 +287,11 @@ hdb_check_aliases(krb5_context context, HDB *db, hdb_entry_ex *entry)
hdb_entry_alias alias;
krb5_data akey, value;
hdb_principal2key(context, &aliases->aliases.val[i], &akey);
code = db->hdb__get(context, db, akey, &value);
krb5_data_free(&akey);
code = hdb_principal2key(context, &aliases->aliases.val[i], &akey);
if (code == 0) {
code = db->hdb__get(context, db, akey, &value);
krb5_data_free(&akey);
}
if (code == HDB_ERR_NOENTRY)
continue;
else if (code)

View File

@@ -635,7 +635,6 @@ hdb_sqlite_store(krb5_context context, HDB *db, unsigned flags,
ret = HDB_ERR_EXISTS;
goto rollback;
}
ret = 0;
ret = bind_principal(context, entry->entry.principal, hsdb->add_principal, 1);
if (ret)
@@ -663,8 +662,6 @@ hdb_sqlite_store(krb5_context context, HDB *db, unsigned flags,
entry_id = sqlite3_column_int64(get_ids, 1);
ret = 0;
} else if(ret == SQLITE_ROW) { /* Found a principal */
if(! (flags & HDB_F_REPLACE)) /* Not allowed to replace it */

View File

@@ -420,6 +420,7 @@ hdb_list_builtin(krb5_context context, char **list)
if (asprintf(&f, "%sfoo", h->prefix) == -1)
f = NULL;
if ((sym = make_sym(h->prefix)) == NULL) {
free(buf);
free(f);
return krb5_enomem(context);
}

View File

@@ -167,15 +167,14 @@ parse_key_set(krb5_context context, const char *key,
salt with, this is mostly useful with null salt for
v4 compat, and a cell name for afs compat */
salt->saltvalue.data = strdup(buf[i]);
if (salt->saltvalue.data == NULL) {
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
return ENOMEM;
}
if (salt->saltvalue.data == NULL)
return krb5_enomem(context);
salt->saltvalue.length = strlen(buf[i]);
}
}
if(enctypes == NULL || salt->salttype == 0) {
krb5_free_salt(context, *salt);
krb5_set_error_message(context, EINVAL, "bad value for default_keys `%s'", key);
return EINVAL;
}
@@ -689,6 +688,7 @@ hdb_generate_key_set(krb5_context context, krb5_principal principal,
if (ret) {
krb5_warn(context, ret, "bad value for default_keys `%s'", *kp);
ret = 0;
krb5_free_salt(context, salt);
continue;
}