From: Tom Yu Date: Mon, 1 Oct 2007 23:13:00 +0000 (+0000) Subject: pull up r19970 from trunk X-Git-Tag: krb5-1.6.3-beta2~41 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0390ec7a8c42f470d7018a068912ed8deade4f7e;p=krb5.git pull up r19970 from trunk r19970@cathode-dark-space: jaltman | 2007-09-24 14:49:58 -0400 ticket: 5766 Remove the broken optimization from UnicodeToANSI() that attempted in a stupid way to avoid to WideCharToMultiByte() call by testing to see if the second byte (not wchar) was NUL. This test works for Latin1 but not for anything more interesting. Always call WideCharToMultiByte(). I commented out the use of WC_NO_BEST_FIT_CHARS in order to provide compatibility with Windows. Windows converts the user name without that option. With the current code a principal name consisting of a single component equivalent to the Greek character Sigma and a realm name will be converted to S@REALM exactly as the "WhoAmI" command does. If WC_NO_BEST_FIT_CHARS was specified, this string would be converted to "?@REALM". ticket: 5766 version_fixed: 1.6.3 git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-6@20047 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/ccache/cc_mslsa.c b/src/lib/krb5/ccache/cc_mslsa.c index c98068c67..80c5b4832 100644 --- a/src/lib/krb5/ccache/cc_mslsa.c +++ b/src/lib/krb5/ccache/cc_mslsa.c @@ -313,25 +313,23 @@ UnicodeToANSI(LPTSTR lpInputString, LPSTR lpszOutputString, int nOutStringLen) return FALSE; } else { if (WideCharToMultiByte(CP_ACP, - WC_NO_BEST_FIT_CHARS | WC_COMPOSITECHECK, + /* WC_NO_BEST_FIT_CHARS | */ WC_COMPOSITECHECK, (LPCWSTR) lpInputString, -1, lpszOutputString, nOutStringLen, NULL, NULL) == 0) return FALSE; } } - else if (((LPBYTE) lpInputString)[1] == '\0') + else { // Looks like unicode, better translate it if (WideCharToMultiByte(CP_ACP, - WC_NO_BEST_FIT_CHARS | WC_COMPOSITECHECK, + /* WC_NO_BEST_FIT_CHARS | */ WC_COMPOSITECHECK, (LPCWSTR) lpInputString, -1, lpszOutputString, nOutStringLen, NULL, NULL) == 0) return FALSE; } - else - lstrcpyA(lpszOutputString, (LPSTR) lpInputString); return TRUE; } // UnicodeToANSI