Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
142afabb
Commit
142afabb
authored
Jan 30, 2013
by
Alex Henrie
Committed by
Alexandre Julliard
Jan 31, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
advapi32: Destination length -1 means no limit.
parent
44593ba6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
14 deletions
+29
-14
crypt.c
dlls/advapi32/crypt.c
+19
-13
crypt.c
dlls/advapi32/tests/crypt.c
+10
-1
No files found.
dlls/advapi32/crypt.c
View file @
142afabb
...
...
@@ -27,6 +27,7 @@
#include "config.h"
#include "wine/port.h"
#include <limits.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
...
...
@@ -109,33 +110,38 @@ static inline PWSTR CRYPT_GetTypeKeyName(DWORD dwType, BOOL user)
return
keyname
;
}
/* CRYPT_UnicodeT
O
ANSI
/* CRYPT_UnicodeT
o
ANSI
* wstr - unicode string
* str - pointer to ANSI string
* strsize - size of buffer pointed to by str
or -1 if we have to do the allocation
* str - pointer to ANSI string
or pointer to null pointer if we have to do the allocation
* strsize - size of buffer pointed to by str
*
* returns TRUE if unsuccessful, FALSE otherwise.
* if wstr is NULL, returns TRUE and sets str to NULL! Value of str should be checked after call
*/
static
inline
BOOL
CRYPT_UnicodeToANSI
(
LPCWSTR
wstr
,
LPSTR
*
str
,
int
strsize
)
{
int
count
;
if
(
!
wstr
)
{
*
str
=
NULL
;
return
TRUE
;
}
count
=
WideCharToMultiByte
(
CP_ACP
,
0
,
wstr
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
if
(
strsize
==
-
1
)
*
str
=
CRYPT_Alloc
(
count
*
sizeof
(
CHAR
));
else
count
=
min
(
count
,
strsize
);
if
(
!*
str
)
{
strsize
=
WideCharToMultiByte
(
CP_ACP
,
0
,
wstr
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
*
str
=
CRYPT_Alloc
(
strsize
*
sizeof
(
CHAR
));
}
else
if
(
strsize
<
0
)
{
strsize
=
INT_MAX
;
/* windows will pretend that the buffer is infinitely long */
}
if
(
*
str
)
{
WideCharToMultiByte
(
CP_ACP
,
0
,
wstr
,
-
1
,
*
str
,
count
,
NULL
,
NULL
);
WideCharToMultiByte
(
CP_ACP
,
0
,
wstr
,
-
1
,
*
str
,
strsize
,
NULL
,
NULL
);
return
TRUE
;
}
SetLastError
(
ERROR_NOT_ENOUGH_MEMORY
);
return
FALSE
;
}
...
...
@@ -481,13 +487,13 @@ BOOL WINAPI CryptAcquireContextW (HCRYPTPROV *phProv, LPCWSTR pszContainer,
goto
error
;
}
pProv
->
pVTable
->
dwProvType
=
dwProvType
;
if
(
!
CRYPT_UnicodeToANSI
(
provname
,
&
provnameA
,
-
1
))
if
(
!
CRYPT_UnicodeToANSI
(
provname
,
&
provnameA
,
0
))
{
/* CRYPT_UnicodeToANSI calls SetLastError */
goto
error
;
}
pProv
->
pVTable
->
pszProvName
=
provnameA
;
if
(
!
CRYPT_UnicodeToANSI
(
pszContainer
,
&
pszContainerA
,
-
1
))
if
(
!
CRYPT_UnicodeToANSI
(
pszContainer
,
&
pszContainerA
,
0
))
{
/* CRYPT_UnicodeToANSI calls SetLastError */
goto
error
;
...
...
dlls/advapi32/tests/crypt.c
View file @
142afabb
...
...
@@ -561,7 +561,16 @@ static void test_enum_providers(void)
if
(
!
(
provider
=
LocalAlloc
(
LMEM_ZEROINIT
,
providerLen
)))
return
;
providerLen
=
0xdeadbeef
;
providerLen
=
-
1
;
result
=
pCryptEnumProvidersA
(
dwIndex
,
NULL
,
0
,
&
type
,
provider
,
&
providerLen
);
ok
(
result
,
"expected TRUE, got %d
\n
"
,
result
);
ok
(
type
==
dwType
,
"expected %d, got %d
\n
"
,
dwType
,
type
);
if
(
pszProvName
)
ok
(
!
strcmp
(
pszProvName
,
provider
),
"expected %s, got %s
\n
"
,
pszProvName
,
provider
);
ok
(
cbName
==
providerLen
,
"expected %d, got %d
\n
"
,
cbName
,
providerLen
);
providerLen
=
-
1000
;
provider
[
0
]
=
0
;
result
=
pCryptEnumProvidersA
(
dwIndex
,
NULL
,
0
,
&
type
,
provider
,
&
providerLen
);
ok
(
result
,
"expected TRUE, got %d
\n
"
,
result
);
ok
(
type
==
dwType
,
"expected %d, got %d
\n
"
,
dwType
,
type
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment