Round #1 of scan-build warnings cleanup

This commit is contained in:
Nicolas Williams
2016-11-15 19:38:04 -06:00
parent 274021f7db
commit 953dc07391
13 changed files with 53 additions and 39 deletions

View File

@@ -424,7 +424,6 @@ dcc_gen_new(krb5_context context, krb5_ccache *id)
dcc_close(context, *id);
return krb5_enomem(context);
}
free(dc->name);
fd = mkstemp(&name[1]);
if (fd < 0) {
@@ -433,6 +432,7 @@ dcc_gen_new(krb5_context context, krb5_ccache *id)
}
close(fd);
free(dc->name);
dc->name = name;
return 0;
@@ -556,6 +556,7 @@ dcc_get_cache_first(krb5_context context, krb5_cc_cursor *cursor)
name = copy_default_dcc_cache(context);
if (name == NULL) {
free(iter);
krb5_set_error_message(context, KRB5_CC_FORMAT,
N_("Can't generate DIR caches unless its the default type", ""));
return KRB5_CC_FORMAT;

View File

@@ -232,13 +232,11 @@ init_cred (krb5_context context,
memset (cred, 0, sizeof(*cred));
if (client)
krb5_copy_principal(context, client, &cred->client);
else {
ret = krb5_get_default_principal (context,
&cred->client);
if (ret)
goto out;
}
ret = krb5_copy_principal(context, client, &cred->client);
else
ret = krb5_get_default_principal(context, &cred->client);
if (ret)
goto out;
if (start_time)
cred->times.starttime = now + start_time;
@@ -532,6 +530,8 @@ change_password (krb5_context context,
char *p;
krb5_get_init_creds_opt *options;
heim_assert(prompter != NULL, "unexpected NULL prompter");
memset (&cpw_cred, 0, sizeof(cpw_cred));
ret = krb5_get_init_creds_opt_alloc(context, &options);
@@ -1933,15 +1933,14 @@ make_fast_ap_fxarmor(krb5_context context,
ALLOC(fxarmor, 1);
if (fxarmor == NULL) {
ret = krb5_enomem(context);
goto out;
}
if (fxarmor == NULL)
return krb5_enomem(context);
if (state->flags & KRB5_FAST_AP_ARMOR_SERVICE) {
#ifdef WIN32
krb5_set_error_message(context, ENOTSUP, "Fast armor IPC service not supportted yet on Windows");
return ENOTSUP;
ret = ENOTSUP;
goto out;
#else /* WIN32 */
KERB_ARMOR_SERVICE_REPLY msg;
krb5_data request, reply;
@@ -1949,7 +1948,8 @@ make_fast_ap_fxarmor(krb5_context context,
heim_base_once_f(&armor_service_once, &armor_service, fast_armor_init_ipc);
if (armor_service == NULL) {
krb5_set_error_message(context, ENOENT, "Failed to open fast armor service");
return ENOENT;
ret = ENOENT;
goto out;
}
krb5_data_zero(&reply);
@@ -1961,7 +1961,7 @@ make_fast_ap_fxarmor(krb5_context context,
heim_release(send);
if (ret) {
krb5_set_error_message(context, ret, "Failed to get armor service credential");
return ret;
goto out;
}
ret = decode_KERB_ARMOR_SERVICE_REPLY(reply.data, reply.length, &msg, NULL);
@@ -2116,6 +2116,8 @@ fast_wrap_req(krb5_context context, struct fast_state *state, KDC_REQ *req)
0,
&fxreq.u.armored_data.enc_fast_req);
krb5_data_free(&data);
if (ret)
goto out;
} else {
krb5_data_free(&data);
@@ -2382,6 +2384,10 @@ krb5_init_creds_step(krb5_context context,
if (ctx->in_tkt_service != NULL && strcmp(ctx->in_tkt_service, "kadmin/changepw") == 0)
goto out;
/* don't try to change password where then where none */
if (ctx->prompter == NULL)
goto out;
ret = change_password(context,
ctx->cred.client,
ctx->password,

View File

@@ -405,7 +405,7 @@ krb5_pac_get_types(krb5_context context,
{
size_t i;
*types = calloc(p->pac->numbuffers, sizeof(*types));
*types = calloc(p->pac->numbuffers, sizeof(**types));
if (*types == NULL) {
*len = 0;
return krb5_enomem(context);
@@ -549,6 +549,8 @@ create_checksum(krb5_context context,
if (cksumtype == (uint32_t)CKSUMTYPE_HMAC_MD5) {
ret = HMAC_MD5_any_checksum(context, key, data, datalen,
KRB5_KU_OTHER_CKSUM, &cksum);
if (ret)
return ret;
} else {
ret = krb5_crypto_init(context, key, 0, &crypto);
if (ret)

View File

@@ -1194,7 +1194,6 @@ scc_get_cache_first(krb5_context context, krb5_cc_cursor *cursor)
}
ret = asprintf(&str, "SELECT name FROM %s", name);
free(name);
if (ret < 0 || str == NULL) {
exec_stmt(context, ctx->db, ctx->drop, 0);
sqlite3_close(ctx->db);
@@ -1203,6 +1202,7 @@ scc_get_cache_first(krb5_context context, krb5_cc_cursor *cursor)
free(ctx);
return krb5_enomem(context);
}
free(name);
ret = prepare_stmt(context, ctx->db, &ctx->stmt, str);
free(str);