From: Tom Yu Date: Thu, 14 Apr 2011 22:04:13 +0000 (+0000) Subject: kadmind frees invalid pointer [MITKRB5-SA-2011-004 CVE-2011-0285] X-Git-Tag: krb5-1.8.4-final~2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=9f0293a1794038489d4764f1b526a9b01e5f8a2a;p=krb5.git kadmind frees invalid pointer [MITKRB5-SA-2011-004 CVE-2011-0285] back-port r24878 for 1.8-branch ------------------------------------------------------------------------ r24878 | tlyu | 2011-04-13 14:43:37 -0400 (Wed, 13 Apr 2011) | 11 lines ticket: 6899 tags: pullup target_version: 1.9.1 Fix the sole case in process_chpw_request() where a return could occur without allocating the data pointer in the response. This prevents a later free() of an invalid pointer in kill_tcp_or_rpc_connection(). Also initialize rep->data to NULL in process_chpw_request() and clean up *response in dispatch() as an additional precaution. ticket: 6900 status: resolved version_fixed: 1.8.4 git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-8@24880 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/kadmin/server/network.c b/src/kadmin/server/network.c index c8ce4f1eb..bb911ffb0 100644 --- a/src/kadmin/server/network.c +++ b/src/kadmin/server/network.c @@ -1384,6 +1384,10 @@ cleanup: if (local_kaddrs != NULL) krb5_free_addresses(server_handle->context, local_kaddrs); + if ((*response)->data == NULL) { + free(*response); + *response = NULL; + } krb5_kt_close(server_handle->context, kt); return ret; diff --git a/src/kadmin/server/schpw.c b/src/kadmin/server/schpw.c index c1b221732..992b55ff4 100644 --- a/src/kadmin/server/schpw.c +++ b/src/kadmin/server/schpw.c @@ -74,8 +74,13 @@ process_chpw_request(context, server_handle, realm, keytab, plen = (*ptr++ & 0xff); plen = (plen<<8) | (*ptr++ & 0xff); - if (plen != req->length) - return(KRB5KRB_AP_ERR_MODIFIED); + if (plen != req->length) { + ret = KRB5KRB_AP_ERR_MODIFIED; + numresult = KRB5_KPASSWD_MALFORMED; + strlcpy(strresult, "Request length was inconsistent", + sizeof(strresult)); + goto chpwfail; + } /* verify version number */