[krbdev.mit.edu #5765] RE: krb5_cc_resolve is crashing in windows XP j
Jeffrey Altman via RT
rt at krbdev.mit.edu
Mon Sep 24 11:48:42 EDT 2007
Revised patch. UnicodeToANSI() could have failed and still returned
success.
Index: cc_mslsa.c
===================================================================
--- cc_mslsa.c (revision 19964)
+++ cc_mslsa.c (working copy)
@@ -312,15 +312,23 @@
{
return FALSE;
} else {
- WideCharToMultiByte(CP_ACP, 0, (LPCWSTR) lpInputString, -1,
- lpszOutputString, nOutStringLen, NULL,
NULL);
+ if (WideCharToMultiByte(CP_ACP,
+ WC_NO_BEST_FIT_CHARS |
WC_COMPOSITECHECK,
+ (LPCWSTR) lpInputString, -1,
+ lpszOutputString,
+ nOutStringLen, NULL, NULL) == 0)
+ return FALSE;
}
}
else if (((LPBYTE) lpInputString)[1] == '\0')
{
// Looks like unicode, better translate it
- WideCharToMultiByte(CP_ACP, 0, (LPCWSTR) lpInputString, -1,
- lpszOutputString, nOutStringLen, NULL, NULL);
+ if (WideCharToMultiByte(CP_ACP,
+ WC_NO_BEST_FIT_CHARS | WC_COMPOSITECHECK,
+ (LPCWSTR) lpInputString, -1,
+ lpszOutputString,
+ nOutStringLen, NULL, NULL) == 0)
+ return FALSE;
}
else
lstrcpyA(lpszOutputString, (LPSTR) lpInputString);
@@ -378,8 +386,8 @@
wcscat(princbuf, L"@");
wcscat(princbuf, realm);
if (UnicodeToANSI(princbuf, aname, sizeof(aname))) {
- krb5_parse_name(context, aname, principal);
- return TRUE;
+ if (krb5_parse_name(context, aname, principal) == 0)
+ return TRUE;
}
return FALSE;
}
@@ -404,8 +412,8 @@
wcscat(princbuf, L"@");
wcscat(princbuf, realm);
if (UnicodeToANSI(princbuf, aname, sizeof(aname))) {
- krb5_parse_name(context, aname, principal);
- return TRUE;
+ if (krb5_parse_name(context, aname, principal) == 0)
+ return TRUE;
}
return FALSE;
}
More information about the krb5-bugs
mailing list