krb5 commit: MSLSA Don't use lstrcpy on ANSI strings

Sam Hartman hartmans at MIT.EDU
Mon Jul 16 09:33:13 EDT 2012


https://github.com/krb5/krb5/commit/7acb524f5aa00274771dbbfac19d2dd779aad409
commit 7acb524f5aa00274771dbbfac19d2dd779aad409
Author: Kevin Wasserman <kevin.wasserman at painless-security.com>
Date:   Fri May 11 11:36:19 2012 -0400

    MSLSA Don't use lstrcpy on ANSI strings
    
    Also change parameter types to eliminate casts.
    
    Signed-off-by: Kevin Wasserman <kevin.wasserman at painless-security.com>
    
    ticket: 7212 (new)
    tags: pullup

 src/lib/krb5/ccache/cc_mslsa.c |   14 +++-----------
 1 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/src/lib/krb5/ccache/cc_mslsa.c b/src/lib/krb5/ccache/cc_mslsa.c
index 098ba29..3d579d6 100644
--- a/src/lib/krb5/ccache/cc_mslsa.c
+++ b/src/lib/krb5/ccache/cc_mslsa.c
@@ -336,23 +336,15 @@ UnicodeToANSI(LPTSTR lpInputString, LPSTR lpszOutputString, int nOutStringLen)
 
 static VOID
 WINAPI
-ANSIToUnicode(LPSTR lpInputString, LPTSTR lpszOutputString, int nOutStringLen)
+ANSIToUnicode(LPCSTR lpInputString, LPWSTR lpszOutputString, int nOutStringLen)
 {
 
     CPINFO CodePageInfo;
 
-    lstrcpy(lpszOutputString, (LPTSTR) lpInputString);
-
     GetCPInfo(CP_ACP, &CodePageInfo);
 
-    if (CodePageInfo.MaxCharSize > 1 || ((LPBYTE) lpInputString)[1] != '\0')
-    {
-        // Looks like ANSI or MultiByte, better translate it
-        MultiByteToWideChar(CP_ACP, 0, (LPCSTR) lpInputString, -1,
-                            (LPWSTR) lpszOutputString, nOutStringLen);
-    }
-    else
-        lstrcpy(lpszOutputString, (LPTSTR) lpInputString);
+    MultiByteToWideChar(CP_ACP, 0, lpInputString, -1,
+                        lpszOutputString, nOutStringLen);
 }  // ANSIToUnicode
 
 


More information about the cvs-krb5 mailing list