krb5int_random_string should probably only fail on malloc
failure. Test for an error return from the function and cleanup
properly (release mutex, return error instead of using uninitialized
memory).
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20655
dc483132-0cff-0310-8789-
dd5450dbe970
* a unique name, or we get an error.
*/
while (1) {
- krb5int_random_string(context, uniquename, sizeof(uniquename));
+ kret = krb5int_random_string(context, uniquename, sizeof(uniquename));
+ if (kret) {
+ k5_mutex_unlock(&krb5int_krcc_mutex);
+ free(lid);
+ return kret;
+ }
+
DEBUG_PRINT(("krb5_krcc_generate_new: searching for name '%s'\n",
uniquename));
key = keyctl_search(ring_id, KRCC_KEY_TYPE_KEYRING, uniquename, 0);
while (1) {
krb5_mcc_list_node *ptr;
- krb5int_random_string (context, uniquename, sizeof (uniquename));
+ err = krb5int_random_string (context, uniquename, sizeof (uniquename));
+ if (err) {
+ k5_mutex_unlock(&krb5int_mcc_mutex);
+ free(lid);
+ return err;
+ }
for (ptr = mcc_head; ptr; ptr=ptr->next) {
if (!strcmp(ptr->cache->name, uniquename)) {