Skip to content

Commit

Permalink
ticket: 4788
Browse files Browse the repository at this point in the history
version_fixed: 1.6

pull up r18897 from trunk

 r18897@cathode-dark-space:  tlyu | 2006-12-01 15:57:04 -0500
 ticket: 4788
 tags: pullup
 target_version: 1.6
 component: krb5-libs
 
 	* src/lib/krb5/ccache/cc_file.c: Adapted patch from Roland
 	Dowdeswell to avoid possible double-free conditions on certain
 	errors.
 



git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-6@18899 dc483132-0cff-0310-8789-dd5450dbe970
  • Loading branch information
tlyu committed Dec 1, 2006
1 parent 9a28b0f commit 511813e
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions src/lib/krb5/ccache/cc_file.c
Expand Up @@ -443,6 +443,8 @@ krb5_fcc_read_principal(krb5_context context, krb5_ccache id, krb5_principal *pr

k5_assert_locked(&((krb5_fcc_data *) id->data)->lock);

*princ = NULL;

if (data->version == KRB5_FCC_FVNO_1) {
type = KRB5_NT_UNKNOWN;
} else {
Expand Down Expand Up @@ -538,15 +540,18 @@ krb5_fcc_read_addrs(krb5_context context, krb5_ccache id, krb5_address ***addrs)
if ((*addrs)[i] == NULL) {
krb5_free_addresses(context, *addrs);
return KRB5_CC_NOMEM;
}
}
(*addrs)[i]->contents = NULL;
kret = krb5_fcc_read_addr(context, id, (*addrs)[i]);
CHECK(kret);
}

return KRB5_OK;
errout:
if (*addrs)
if (*addrs) {
krb5_free_addresses(context, *addrs);
*addrs = NULL;
}
return kret;
}

Expand Down Expand Up @@ -593,8 +598,10 @@ krb5_fcc_read_keyblock(krb5_context context, krb5_ccache id, krb5_keyblock *keyb

return KRB5_OK;
errout:
if (keyblock->contents)
if (keyblock->contents) {
krb5_xfree(keyblock->contents);
keyblock->contents = NULL;
}
return kret;
}

Expand Down Expand Up @@ -632,8 +639,10 @@ krb5_fcc_read_data(krb5_context context, krb5_ccache id, krb5_data *data)
data->data[data->length] = 0; /* Null terminate, just in case.... */
return KRB5_OK;
errout:
if (data->data)
if (data->data) {
krb5_xfree(data->data);
data->data = NULL;
}
return kret;
}

Expand Down Expand Up @@ -675,8 +684,10 @@ krb5_fcc_read_addr(krb5_context context, krb5_ccache id, krb5_address *addr)

return KRB5_OK;
errout:
if (addr->contents)
if (addr->contents) {
krb5_xfree(addr->contents);
addr->contents = NULL;
}
return kret;
}

Expand Down Expand Up @@ -804,15 +815,18 @@ krb5_fcc_read_authdata(krb5_context context, krb5_ccache id, krb5_authdata ***a)
if ((*a)[i] == NULL) {
krb5_free_authdata(context, *a);
return KRB5_CC_NOMEM;
}
}
(*a)[i]->contents = NULL;
kret = krb5_fcc_read_authdatum(context, id, (*a)[i]);
CHECK(kret);
}

return KRB5_OK;
errout:
if (*a)
if (*a) {
krb5_free_authdata(context, *a);
*a = NULL;
}
return kret;
}

Expand Down Expand Up @@ -853,8 +867,10 @@ krb5_fcc_read_authdatum(krb5_context context, krb5_ccache id, krb5_authdata *a)

return KRB5_OK;
errout:
if (a->contents)
if (a->contents) {
krb5_xfree(a->contents);
a->contents = NULL;
}
return kret;

}
Expand Down

0 comments on commit 511813e

Please sign in to comment.