test leak and make behavie sanely.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25025 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -740,6 +740,8 @@ fcc_remove_cred(krb5_context context,
|
|||||||
{
|
{
|
||||||
krb5_error_code ret;
|
krb5_error_code ret;
|
||||||
krb5_ccache copy, newfile;
|
krb5_ccache copy, newfile;
|
||||||
|
char *newname;
|
||||||
|
int fd;
|
||||||
|
|
||||||
ret = krb5_cc_gen_new(context, &krb5_mcc_ops, ©);
|
ret = krb5_cc_gen_new(context, &krb5_mcc_ops, ©);
|
||||||
if (ret)
|
if (ret)
|
||||||
@@ -757,8 +759,24 @@ fcc_remove_cred(krb5_context context,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = krb5_cc_gen_new(context, &krb5_fcc_ops, &newfile);
|
asprintf(&newname, "FILE:%s.XXXXXX", FILENAME(id));
|
||||||
|
if (newname == NULL) {
|
||||||
|
krb5_cc_destroy(context, copy);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
fd = mkstemp(&newname[5]);
|
||||||
|
if (fd < 0) {
|
||||||
|
ret = errno;
|
||||||
|
krb5_cc_destroy(context, copy);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
close(fd);
|
||||||
|
|
||||||
|
ret = krb5_cc_resolve(context, newname, &newfile);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
unlink(&newname[5]);
|
||||||
|
free(newname);
|
||||||
krb5_cc_destroy(context, copy);
|
krb5_cc_destroy(context, copy);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -766,15 +784,16 @@ fcc_remove_cred(krb5_context context,
|
|||||||
ret = krb5_cc_copy_cache(context, copy, newfile);
|
ret = krb5_cc_copy_cache(context, copy, newfile);
|
||||||
krb5_cc_destroy(context, copy);
|
krb5_cc_destroy(context, copy);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
free(newname);
|
||||||
krb5_cc_destroy(context, newfile);
|
krb5_cc_destroy(context, newfile);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = krb5_cc_move(context, newfile, id);
|
ret = rename(&newname[5], FILENAME(id));
|
||||||
if (ret) {
|
if (ret)
|
||||||
krb5_cc_destroy(context, newfile);
|
ret = errno;
|
||||||
return ret;
|
free(newname);
|
||||||
}
|
krb5_cc_close(context, newfile);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user