Fix resource leak in heimdal/krb5/fcache/fcc_remove_cred
In fcache, fcc_remove_cred generates a ccache called
"newfile," which is not cleaned up if the final call
(krb5_cc_move) fails.
Free of uninitialized value in fcache/fcc_move(...)
If init_fcc fails to acquire a file handle, sp will be
uninitialized. If this is the case, the call to
krb5_storage_free will dereference this uninitialized value,
which causes undefined behaviour.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24944
ec53bebd-3082-4978-b11e-
865c3cabbd6b
return ret;
}
- return krb5_cc_move(context, newfile, id);
+ ret = krb5_cc_move(context, newfile, id);
+ if (ret) {
+ krb5_cc_destroy(context, newfile);
+ return ret;
+ }
+
+ return ret;
}
static krb5_error_code
krb5_storage *sp;
int fd;
ret = init_fcc (context, to, &sp, &fd);
- krb5_storage_free(sp);
+ if (sp)
+ krb5_storage_free(sp);
fcc_unlock(context, fd);
close(fd);
}