[PATCH] advapi32: fixed second buffer argument to MBtoWC and WCtoMB
Marcus Meissner
marcus at jet.franken.de
Wed Feb 4 13:29:39 CST 2009
Hi,
Passing -1 as target buffersize to MBtoWC and WCtoMB is
undefined, so do not do it.
Ciao, Marcus
---
dlls/advapi32/cred.c | 24 ++++++++++++++++--------
1 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/dlls/advapi32/cred.c b/dlls/advapi32/cred.c
index 9ad4fb1..ab86ed6 100644
--- a/dlls/advapi32/cred.c
+++ b/dlls/advapi32/cred.c
@@ -940,7 +940,8 @@ static void convert_PCREDENTIALW_to_PCREDENTIALA(const CREDENTIALW *CredentialW,
if (CredentialW->TargetName)
{
CredentialA->TargetName = buffer;
- string_len = WideCharToMultiByte(CP_ACP, 0, CredentialW->TargetName, -1, CredentialA->TargetName, -1, NULL, NULL);
+ string_len = WideCharToMultiByte(CP_ACP, 0, CredentialW->TargetName, -1, NULL, 0, NULL, NULL);
+ WideCharToMultiByte(CP_ACP, 0, CredentialW->TargetName, -1, CredentialA->TargetName, string_len, NULL, NULL);
buffer += string_len;
*len += string_len;
}
@@ -949,7 +950,8 @@ static void convert_PCREDENTIALW_to_PCREDENTIALA(const CREDENTIALW *CredentialW,
if (CredentialW->Comment)
{
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, NULL, 0, NULL, NULL);
+ WideCharToMultiByte(CP_ACP, 0, CredentialW->Comment, -1, CredentialA->Comment, string_len, NULL, NULL);
buffer += string_len;
*len += string_len;
}
@@ -973,7 +975,8 @@ static void convert_PCREDENTIALW_to_PCREDENTIALA(const CREDENTIALW *CredentialW,
if (CredentialW->TargetAlias)
{
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, NULL, 0, NULL, NULL);
+ WideCharToMultiByte(CP_ACP, 0, CredentialW->TargetAlias, -1, CredentialA->TargetAlias, string_len, NULL, NULL);
buffer += string_len;
*len += string_len;
}
@@ -982,7 +985,8 @@ static void convert_PCREDENTIALW_to_PCREDENTIALA(const CREDENTIALW *CredentialW,
if (CredentialW->UserName)
{
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, NULL, 0, NULL, NULL);
+ WideCharToMultiByte(CP_ACP, 0, CredentialW->UserName, -1, CredentialA->UserName, string_len, NULL, NULL);
buffer += string_len;
*len += string_len;
}
@@ -1012,7 +1016,8 @@ static void convert_PCREDENTIALA_to_PCREDENTIALW(const CREDENTIALA *CredentialA,
if (CredentialA->TargetName)
{
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, NULL, 0);
+ MultiByteToWideChar(CP_ACP, 0, CredentialA->TargetName, -1, CredentialW->TargetName, string_len);
buffer += sizeof(WCHAR) * string_len;
*len += sizeof(WCHAR) * string_len;
}
@@ -1021,7 +1026,8 @@ static void convert_PCREDENTIALA_to_PCREDENTIALW(const CREDENTIALA *CredentialA,
if (CredentialA->Comment)
{
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, NULL, 0);
+ MultiByteToWideChar(CP_ACP, 0, CredentialA->Comment, -1, CredentialW->Comment, string_len);
buffer += sizeof(WCHAR) * string_len;
*len += sizeof(WCHAR) * string_len;
}
@@ -1045,7 +1051,8 @@ static void convert_PCREDENTIALA_to_PCREDENTIALW(const CREDENTIALA *CredentialA,
if (CredentialA->TargetAlias)
{
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, NULL, 0);
+ MultiByteToWideChar(CP_ACP, 0, CredentialA->TargetAlias, -1, CredentialW->TargetAlias, string_len);
buffer += sizeof(WCHAR) * string_len;
*len += sizeof(WCHAR) * string_len;
}
@@ -1054,7 +1061,8 @@ static void convert_PCREDENTIALA_to_PCREDENTIALW(const CREDENTIALA *CredentialA,
if (CredentialA->UserName)
{
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, NULL, 0);
+ MultiByteToWideChar(CP_ACP, 0, CredentialA->UserName, -1, CredentialW->UserName, string_len);
buffer += sizeof(WCHAR) * string_len;
*len += sizeof(WCHAR) * string_len;
}
--
1.5.6
More information about the wine-patches
mailing list