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

@@ -1754,8 +1754,10 @@ krb5_cc_get_lifetime(krb5_context context, krb5_ccache id, time_t *t)
return krb5_enomem(context);
ret = krb5_cc_start_seq_get(context, id, &cursor);
if (ret)
if (ret) {
free(start_realm);
return ret;
}
while ((ret = krb5_cc_next_cred(context, id, &cursor, &cred)) == 0) {
/**

View File

@@ -547,8 +547,10 @@ static krb5_error_code KRB5_CALLCONV
dcc_get_cache_first(krb5_context context, krb5_cc_cursor *cursor)
{
struct dcache_iter *iter;
krb5_error_code ret;
char *name;
*cursor = NULL;
iter = calloc(1, sizeof(*iter));
if (iter == NULL)
return krb5_enomem(context);
@@ -562,18 +564,17 @@ dcc_get_cache_first(krb5_context context, krb5_cc_cursor *cursor)
return KRB5_CC_FORMAT;
}
#if 1
free(name);
return KRB5_CC_FORMAT;
#else
/* XXX */
ret = dcc_resolve(context, NULL, name);
free(name);
if (ret) {
free(iter);
return ret;
}
/* XXX We need to opendir() here */
*cursor = iter;
return 0;
#endif
}
static krb5_error_code KRB5_CALLCONV
@@ -588,6 +589,8 @@ dcc_get_cache_next(krb5_context context, krb5_cc_cursor cursor, krb5_ccache *id)
krb5_clear_error_message(context);
return KRB5_CC_END;
}
/* XXX We need to readdir() here */
iter->first = 0;
return KRB5_CC_END;
@@ -601,6 +604,7 @@ dcc_end_cache_get(krb5_context context, krb5_cc_cursor cursor)
if (iter == NULL)
return krb5_einval(context, 2);
/* XXX We need to closedir() here */
if (iter->dc)
dcc_release(context, iter->dc);
free(iter);

View File

@@ -465,7 +465,6 @@ _krb5_expand_path_tokensv(krb5_context context,
char *tok_begin, *tok_end, *append;
char **extra_tokens = NULL;
const char *path_left;
const char *s;
size_t nargs = 0;
size_t len = 0;
va_list ap;
@@ -478,9 +477,9 @@ _krb5_expand_path_tokensv(krb5_context context,
*ppath_out = NULL;
va_start(ap, ppath_out);
while ((s = va_arg(ap, const char *))) {
while (va_arg(ap, const char *)) {
nargs++;
s = va_arg(ap, const char *);
va_arg(ap, const char *);
}
va_end(ap);
nargs *= 2;
@@ -494,7 +493,7 @@ _krb5_expand_path_tokensv(krb5_context context,
return krb5_enomem(context);
va_start(ap, ppath_out);
for (i = 0; i < nargs; i++) {
s = va_arg(ap, const char *); /* token key */
char *s = va_arg(ap, const char *); /* token key */
if (s == NULL)
break;
extra_tokens[i] = strdup(s);

View File

@@ -964,12 +964,12 @@ cred_delete(krb5_context context,
if (srealm && strcmp(srealm, "X-CACHECONF:") == 0) {
ret = krb5_principal_set_realm(context, cred->server, "X-RMED-CONF:");
if (ret)
return;
goto out;
}
sp = krb5_storage_emem();
if (sp == NULL)
return;
goto out;
krb5_storage_set_eof_code(sp, KRB5_CC_END);
storage_set_flags(context, sp, FCACHE(id)->version);

View File

@@ -486,6 +486,8 @@ loop:
if(start) *start = pos;
if(end) *end = pos + 4 + len;
out:
if (ret)
krb5_kt_free_entry(context, entry);
krb5_storage_seek(cursor->sp, pos + 4 + len, SEEK_SET);
return ret;
}

View File

@@ -127,7 +127,7 @@ static krb5_error_code KRB5_CALLCONV
akf_resolve(krb5_context context, const char *name, krb5_keytab id)
{
int ret;
struct akf_data *d = malloc(sizeof (struct akf_data));
struct akf_data *d = calloc(1, sizeof (struct akf_data));
if (d == NULL)
return krb5_enomem(context);

View File

@@ -307,8 +307,10 @@ cert2epi(hx509_context context, void *ctx, hx509_cert c)
id.issuerAndSerialNumber->length,
&iasn, &size, ret);
free_IssuerAndSerialNumber(&iasn);
if (ret)
if (ret) {
free_ExternalPrincipalIdentifier(&id);
return ret;
}
if (id.issuerAndSerialNumber->length != size)
abort();
}

View File

@@ -1357,6 +1357,7 @@ krb5_sname_to_principal(krb5_context context,
if (ret) {
_krb5_debug(context, 5, "Failed to get name canon rules: ret = %d",
ret);
free(remote_host);
return ret;
}
if (rules[0].type == KRB5_NCRT_NSS &&
@@ -1784,8 +1785,6 @@ apply_name_canon_rule(krb5_context context, krb5_name_canon_rule rules,
if (ndots > rule->maxdots)
return 0;
ret = 0;
if (rule->match_domain != NULL &&
!is_domain_suffix(orig_hostname, rule->match_domain))
return 0;

View File

@@ -450,6 +450,7 @@ krb5_ret_int(krb5_storage *sp,
int ret;
unsigned char v[8];
uint64_t w;
*value = 0; /* quiets warnings */
ret = sp->fetch(sp, v, len);
if (ret < 0)
return errno;