Fix Wine-ish code, which doesn't work in ReactOS and only works in Wine by accident

svn path=/trunk/; revision=35128
This commit is contained in:
Colin Finck 2008-08-05 16:30:03 +00:00
parent e55530aef8
commit c20321a3f6

View file

@ -26,13 +26,6 @@
#include "winreg.h" #include "winreg.h"
#include "wincred.h" #include "wincred.h"
#include "winternl.h" #include "winternl.h"
#ifdef __APPLE__
# include <Security/SecKeychain.h>
# include <Security/SecKeychainItem.h>
# include <Security/SecKeychainSearch.h>
#endif
#include "../crypt/crypt.h" #include "../crypt/crypt.h"
#include "wine/unicode.h" #include "wine/unicode.h"
@ -946,7 +939,10 @@ static void convert_PCREDENTIALW_to_PCREDENTIALA(const CREDENTIALW *CredentialW,
if (CredentialW->TargetName) if (CredentialW->TargetName)
{ {
CredentialA->TargetName = buffer; CredentialA->TargetName = buffer;
string_len = WideCharToMultiByte(CP_ACP, 0, CredentialW->TargetName, -1, CredentialA->TargetName, -1, NULL, NULL);
/* Buffer is guaranteed to be large enough */
string_len = WideCharToMultiByte(CP_ACP, 0, CredentialW->TargetName, -1, CredentialA->TargetName, 0x7FFFFFFF, NULL, NULL);
buffer += string_len; buffer += string_len;
*len += string_len; *len += string_len;
} }
@ -955,7 +951,7 @@ static void convert_PCREDENTIALW_to_PCREDENTIALA(const CREDENTIALW *CredentialW,
if (CredentialW->Comment) if (CredentialW->Comment)
{ {
CredentialA->Comment = buffer; CredentialA->Comment = buffer;
string_len = WideCharToMultiByte(CP_ACP, 0, CredentialW->Comment, -1, CredentialA->Comment, -1, NULL, NULL); string_len = WideCharToMultiByte(CP_ACP, 0, CredentialW->Comment, -1, CredentialA->Comment, 0x7FFFFFFF, NULL, NULL);
buffer += string_len; buffer += string_len;
*len += string_len; *len += string_len;
} }
@ -979,7 +975,7 @@ static void convert_PCREDENTIALW_to_PCREDENTIALA(const CREDENTIALW *CredentialW,
if (CredentialW->TargetAlias) if (CredentialW->TargetAlias)
{ {
CredentialA->TargetAlias = buffer; CredentialA->TargetAlias = buffer;
string_len = WideCharToMultiByte(CP_ACP, 0, CredentialW->TargetAlias, -1, CredentialA->TargetAlias, -1, NULL, NULL); string_len = WideCharToMultiByte(CP_ACP, 0, CredentialW->TargetAlias, -1, CredentialA->TargetAlias, 0x7FFFFFFF, NULL, NULL);
buffer += string_len; buffer += string_len;
*len += string_len; *len += string_len;
} }
@ -988,7 +984,7 @@ static void convert_PCREDENTIALW_to_PCREDENTIALA(const CREDENTIALW *CredentialW,
if (CredentialW->UserName) if (CredentialW->UserName)
{ {
CredentialA->UserName = buffer; CredentialA->UserName = buffer;
string_len = WideCharToMultiByte(CP_ACP, 0, CredentialW->UserName, -1, CredentialA->UserName, -1, NULL, NULL); string_len = WideCharToMultiByte(CP_ACP, 0, CredentialW->UserName, -1, CredentialA->UserName, 0x7FFFFFFF, NULL, NULL);
buffer += string_len; buffer += string_len;
*len += string_len; *len += string_len;
} }
@ -1018,7 +1014,7 @@ static void convert_PCREDENTIALA_to_PCREDENTIALW(const CREDENTIALA *CredentialA,
if (CredentialA->TargetName) if (CredentialA->TargetName)
{ {
CredentialW->TargetName = (LPWSTR)buffer; CredentialW->TargetName = (LPWSTR)buffer;
string_len = MultiByteToWideChar(CP_ACP, 0, CredentialA->TargetName, -1, CredentialW->TargetName, -1); string_len = MultiByteToWideChar(CP_ACP, 0, CredentialA->TargetName, -1, CredentialW->TargetName, 0x7FFFFFFF);
buffer += sizeof(WCHAR) * string_len; buffer += sizeof(WCHAR) * string_len;
*len += sizeof(WCHAR) * string_len; *len += sizeof(WCHAR) * string_len;
} }
@ -1027,7 +1023,7 @@ static void convert_PCREDENTIALA_to_PCREDENTIALW(const CREDENTIALA *CredentialA,
if (CredentialA->Comment) if (CredentialA->Comment)
{ {
CredentialW->Comment = (LPWSTR)buffer; CredentialW->Comment = (LPWSTR)buffer;
string_len = MultiByteToWideChar(CP_ACP, 0, CredentialA->Comment, -1, CredentialW->Comment, -1); string_len = MultiByteToWideChar(CP_ACP, 0, CredentialA->Comment, -1, CredentialW->Comment, 0x7FFFFFFF);
buffer += sizeof(WCHAR) * string_len; buffer += sizeof(WCHAR) * string_len;
*len += sizeof(WCHAR) * string_len; *len += sizeof(WCHAR) * string_len;
} }
@ -1051,7 +1047,7 @@ static void convert_PCREDENTIALA_to_PCREDENTIALW(const CREDENTIALA *CredentialA,
if (CredentialA->TargetAlias) if (CredentialA->TargetAlias)
{ {
CredentialW->TargetAlias = (LPWSTR)buffer; CredentialW->TargetAlias = (LPWSTR)buffer;
string_len = MultiByteToWideChar(CP_ACP, 0, CredentialA->TargetAlias, -1, CredentialW->TargetAlias, -1); string_len = MultiByteToWideChar(CP_ACP, 0, CredentialA->TargetAlias, -1, CredentialW->TargetAlias, 0x7FFFFFFF);
buffer += sizeof(WCHAR) * string_len; buffer += sizeof(WCHAR) * string_len;
*len += sizeof(WCHAR) * string_len; *len += sizeof(WCHAR) * string_len;
} }
@ -1060,7 +1056,7 @@ static void convert_PCREDENTIALA_to_PCREDENTIALW(const CREDENTIALA *CredentialA,
if (CredentialA->UserName) if (CredentialA->UserName)
{ {
CredentialW->UserName = (LPWSTR)buffer; CredentialW->UserName = (LPWSTR)buffer;
string_len = MultiByteToWideChar(CP_ACP, 0, CredentialA->UserName, -1, CredentialW->UserName, -1); string_len = MultiByteToWideChar(CP_ACP, 0, CredentialA->UserName, -1, CredentialW->UserName, 0x7FFFFFFF);
buffer += sizeof(WCHAR) * string_len; buffer += sizeof(WCHAR) * string_len;
*len += sizeof(WCHAR) * string_len; *len += sizeof(WCHAR) * string_len;
} }