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
f714cf4b
Commit
f714cf4b
authored
Nov 06, 2008
by
Nicolas Le Cam
Committed by
Alexandre Julliard
Nov 07, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
advapi32/tests: test_enum_provider_types test cleanup.
parent
30a6f54d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
62 deletions
+73
-62
crypt.c
dlls/advapi32/tests/crypt.c
+73
-62
No files found.
dlls/advapi32/tests/crypt.c
View file @
f714cf4b
...
...
@@ -566,43 +566,51 @@ static BOOL FindProvTypesRegVals(DWORD dwIndex, DWORD *pdwProvType, LPSTR *pszTy
HKEY
hKey
;
HKEY
hSubKey
;
PSTR
ch
;
LPSTR
szName
;
DWORD
cbName
;
BOOL
ret
=
FALSE
;
if
(
RegOpenKey
(
HKEY_LOCAL_MACHINE
,
"Software
\\
Microsoft
\\
Cryptography
\\
Defaults
\\
Provider Types"
,
&
hKey
))
return
FALSE
;
if
(
RegQueryInfoKey
(
hKey
,
NULL
,
NULL
,
NULL
,
pdwTypeCount
,
pcbType
Name
,
NULL
,
if
(
RegQueryInfoKey
(
hKey
,
NULL
,
NULL
,
NULL
,
pdwTypeCount
,
&
cb
Name
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
))
return
FALSE
;
(
*
pcbTypeName
)
++
;
if
(
!
(
*
pszTypeName
=
((
LPSTR
)
LocalAlloc
(
LMEM_ZEROINIT
,
*
pcbTypeName
)
)))
return
FALSE
;
if
(
RegEnumKeyEx
(
hKey
,
dwIndex
,
*
pszTypeName
,
pcbType
Name
,
NULL
,
NULL
,
NULL
,
NULL
))
return
FALSE
;
(
*
pcbTypeName
)
++
;
ch
=
*
pszTypeName
+
strlen
(
*
pszType
Name
);
goto
cleanup
;
cbName
++
;
if
(
!
(
szName
=
LocalAlloc
(
LMEM_ZEROINIT
,
cbName
)))
goto
cleanup
;
if
(
RegEnumKeyEx
(
hKey
,
dwIndex
,
szName
,
&
cb
Name
,
NULL
,
NULL
,
NULL
,
NULL
))
goto
cleanup
;
cbName
++
;
ch
=
szName
+
strlen
(
sz
Name
);
/* Convert "Type 000" to 0, etc/ */
*
pdwProvType
=
*
(
--
ch
)
-
'0'
;
*
pdwProvType
+=
(
*
(
--
ch
)
-
'0'
)
*
10
;
*
pdwProvType
+=
(
*
(
--
ch
)
-
'0'
)
*
100
;
if
(
RegOpenKey
(
hKey
,
*
pszType
Name
,
&
hSubKey
))
return
FALSE
;
if
(
RegOpenKey
(
hKey
,
sz
Name
,
&
hSubKey
))
goto
cleanup
;
if
(
RegQueryValueEx
(
hSubKey
,
"TypeName"
,
NULL
,
NULL
,
NULL
,
pcbTypeName
))
return
FALSE
;
goto
cleanup
;
if
(
!
(
*
pszTypeName
=
LocalAlloc
(
LMEM_ZEROINIT
,
*
pcbTypeName
)))
goto
cleanup
;
if
(
!
RegQueryValueEx
(
hSubKey
,
"TypeName"
,
NULL
,
NULL
,
(
LPBYTE
)
*
pszTypeName
,
pcbTypeName
))
ret
=
TRUE
;
cleanup:
if
(
!
ret
)
LocalFree
(
*
pszTypeName
);
LocalFree
(
szName
);
if
(
!
(
*
pszTypeName
=
((
LPSTR
)
LocalAlloc
(
LMEM_ZEROINIT
,
*
pcbTypeName
))))
return
FALSE
;
if
(
RegQueryValueEx
(
hSubKey
,
"TypeName"
,
NULL
,
NULL
,
(
LPBYTE
)
*
pszTypeName
,
pcbTypeName
))
return
FALSE
;
RegCloseKey
(
hSubKey
);
RegCloseKey
(
hKey
);
return
TRUE
;
return
ret
;
}
static
void
test_enum_provider_types
(
void
)
...
...
@@ -612,7 +620,7 @@ static void test_enum_provider_types(void)
LPSTR
pszTypeName
=
NULL
;
DWORD
cbTypeName
;
DWORD
dwTypeCount
;
/* actual values */
DWORD
index
=
0
;
DWORD
provType
;
...
...
@@ -622,45 +630,47 @@ static void test_enum_provider_types(void)
DWORD
result
;
DWORD
notNull
=
5
;
DWORD
notZeroFlags
=
5
;
if
(
!
pCryptEnumProviderTypesA
)
{
skip
(
"CryptEnumProviderTypesA is not available
\n
"
);
return
;
skip
(
"CryptEnumProviderTypesA is not available
\n
"
);
return
;
}
if
(
!
FindProvTypesRegVals
(
index
,
&
dwProvType
,
&
pszTypeName
,
&
cbTypeName
,
&
dwTypeCount
))
{
skip
(
"Could not find provider types in registry
\n
"
);
return
;
skip
(
"Could not find provider types in registry
\n
"
);
return
;
}
/* check pdwReserved for NULL */
result
=
pCryptEnumProviderTypesA
(
index
,
&
notNull
,
0
,
&
provType
,
typeName
,
&
typeNameSize
);
ok
(
!
result
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"expected
%i, got %d
\n
"
,
ERROR_INVALID_PARAMETER
,
GetLastError
());
ok
(
!
result
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"expected
ERROR_INVALID_PARAMETER, got %d
\n
"
,
GetLastError
());
/* check dwFlags == zero */
result
=
pCryptEnumProviderTypesA
(
index
,
NULL
,
notZeroFlags
,
&
provType
,
typeName
,
&
typeNameSize
);
ok
(
!
result
&&
GetLastError
()
==
NTE_BAD_FLAGS
,
"expected %i, got %d
\n
"
,
ERROR_INVALID_PARAMETER
,
GetLastError
());
/* alloc provider type to half the size required
* cbTypeName holds the size required */
typeNameSize
=
cbTypeName
/
2
;
if
(
!
(
typeName
=
((
LPSTR
)
LocalAlloc
(
LMEM_ZEROINIT
,
typeNameSize
))))
return
;
ok
(
!
result
&&
GetLastError
()
==
NTE_BAD_FLAGS
,
"expected ERROR_INVALID_PARAMETER, got %d
\n
"
,
GetLastError
());
/* This test fails under Win2k SP4:
result = TRUE, GetLastError() == 0xdeadbeef
SetLastError(0xdeadbeef);
result = pCryptEnumProviderTypesA(index, NULL, 0, &provType, typeName, &typeNameSize);
ok(!result && GetLastError()==ERROR_MORE_DATA, "expected 0/ERROR_MORE_DATA, got %d/%08lx\n",
result, GetLastError());
*/
LocalFree
(
typeName
);
* result = TRUE, GetLastError() == 0xdeadbeef */
if
(
0
)
{
/* alloc provider type to half the size required
* cbTypeName holds the size required */
typeNameSize
=
cbTypeName
/
2
;
if
(
!
(
typeName
=
((
LPSTR
)
LocalAlloc
(
LMEM_ZEROINIT
,
typeNameSize
))))
goto
cleanup
;
SetLastError
(
0xdeadbeef
);
result
=
pCryptEnumProviderTypesA
(
index
,
NULL
,
0
,
&
provType
,
typeName
,
&
typeNameSize
);
ok
(
!
result
&&
GetLastError
()
==
ERROR_MORE_DATA
,
"expected 0/ERROR_MORE_DATA, got %d/%d
\n
"
,
result
,
GetLastError
());
LocalFree
(
typeName
);
}
/* loop through the provider types to get the number of provider types
* after loop ends, count should be dwTypeCount + 1 so subtract 1
* to get actual number of provider types */
...
...
@@ -669,30 +679,31 @@ static void test_enum_provider_types(void)
;
typeCount
--
;
ok
(
typeCount
==
dwTypeCount
,
"expected %d, got %d
\n
"
,
dwTypeCount
,
typeCount
);
/* loop past the actual number of provider types to get the error
* ERROR_NO_MORE_ITEMS */
for
(
typeCount
=
0
;
typeCount
<
dwTypeCount
+
1
;
typeCount
++
)
result
=
pCryptEnumProviderTypesA
(
typeCount
,
NULL
,
0
,
&
provType
,
NULL
,
&
typeNameSize
);
ok
(
!
result
&&
GetLastError
()
==
ERROR_NO_MORE_ITEMS
,
"expected %i, got %d
\n
"
,
ERROR_NO_MORE_ITEMS
,
GetLastError
());
ok
(
!
result
&&
GetLastError
()
==
ERROR_NO_MORE_ITEMS
,
"expected ERROR_NO_MORE_ITEMS, got %d
\n
"
,
GetLastError
());
/* check expected versus actual values returned */
result
=
pCryptEnumProviderTypesA
(
index
,
NULL
,
0
,
&
provType
,
NULL
,
&
typeNameSize
);
ok
(
result
&&
typeNameSize
==
cbTypeName
,
"expected %d, got %d
\n
"
,
cbTypeName
,
typeNameSize
);
if
(
!
(
typeName
=
((
LPSTR
)
LocalAlloc
(
LMEM_ZEROINIT
,
typeNameSize
))))
return
;
goto
cleanup
;
typeNameSize
=
0xdeadbeef
;
result
=
pCryptEnumProviderTypesA
(
index
,
NULL
,
0
,
&
provType
,
typeName
,
&
typeNameSize
);
ok
(
result
,
"expected TRUE, got %d
\n
"
,
result
);
ok
(
provType
==
dwProvType
,
"expected %d, got %d
\n
"
,
dwProvType
,
provType
);
if
(
pszTypeName
)
ok
(
!
strcmp
(
pszTypeName
,
typeName
),
"expected %s, got %s
\n
"
,
pszTypeName
,
typeName
);
ok
(
!
strcmp
(
pszTypeName
,
typeName
),
"expected %s, got %s
\n
"
,
pszTypeName
,
typeName
);
ok
(
typeNameSize
==
cbTypeName
,
"expected %d, got %d
\n
"
,
cbTypeName
,
typeNameSize
);
LocalFree
(
typeName
);
cleanup:
LocalFree
(
pszTypeName
);
}
static
BOOL
FindDfltProvRegVals
(
DWORD
dwProvType
,
DWORD
dwFlags
,
LPSTR
*
pszProvName
,
DWORD
*
pcbProvName
)
...
...
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