Potential memory leaks in ipa-kpasswd

This patch fixes 2 situations where a pointer to allocated error
string could be overwritten - which could have resulted in
a memory leak.

https://fedorahosted.org/freeipa/ticket/716
This commit is contained in:
Martin Kosek 2011-01-12 13:19:21 +01:00 committed by Simo Sorce
parent c69d8084c1
commit 63e70d052c

View File

@ -925,6 +925,9 @@ kpreply:
kdec.data[1] = result_err & 0xff;
memcpy(&kdec.data[2], result_string, strlen(result_string));
free(result_string);
result_string = NULL;
krberr = krb5_auth_con_setaddrs(context, auth_context, &lkaddr, NULL);
if (krberr) {
result_string = strdup("Failed to set local address");
@ -938,6 +941,9 @@ kpreply:
result_string = strdup("Failed to encrypt reply message");
syslog(LOG_ERR, "%s: %s", result_string,
krb5_get_error_message(context, krberr));
free(result_string);
result_string = NULL;
/* encryption was unsuccessful, let's return a krb error */
/* the ap data is no more useful */