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
6db69d02
Commit
6db69d02
authored
Sep 07, 2023
by
Alex Henrie
Committed by
Alexandre Julliard
Sep 08, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wintrust: Use CRT allocation functions.
parent
537bcadb
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
104 deletions
+61
-104
crypt.c
dlls/wintrust/crypt.c
+0
-0
register.c
dlls/wintrust/register.c
+27
-21
softpub.c
dlls/wintrust/softpub.c
+2
-2
wintrust_main.c
dlls/wintrust/wintrust_main.c
+32
-78
wintrust_priv.h
dlls/wintrust/wintrust_priv.h
+0
-3
No files found.
dlls/wintrust/crypt.c
View file @
6db69d02
This diff is collapsed.
Click to expand it.
dlls/wintrust/register.c
View file @
6db69d02
...
...
@@ -92,10 +92,8 @@ static void WINTRUST_InitRegStructs(void)
{
#define WINTRUST_INITREGENTRY( action, dllname, functionname ) \
action.cbStruct = sizeof(CRYPT_TRUST_REG_ENTRY); \
action.pwszDLLName = WINTRUST_Alloc(sizeof(dllname)); \
lstrcpyW(action.pwszDLLName, dllname); \
action.pwszFunctionName = WINTRUST_Alloc(sizeof(functionname)); \
lstrcpyW(action.pwszFunctionName, functionname);
action.pwszDLLName = wcsdup(dllname); \
action.pwszFunctionName = wcsdup(functionname);
WINTRUST_INITREGENTRY
(
SoftpubInitialization
,
SP_POLICY_PROVIDER_DLL_NAME
,
SP_INIT_FUNCTION
)
WINTRUST_INITREGENTRY
(
SoftpubMessage
,
SP_POLICY_PROVIDER_DLL_NAME
,
SP_OBJTRUST_FUNCTION
)
...
...
@@ -128,8 +126,8 @@ static void WINTRUST_InitRegStructs(void)
static
void
WINTRUST_FreeRegStructs
(
void
)
{
#define WINTRUST_FREEREGENTRY( action ) \
WINTRUST_F
ree(action.pwszDLLName); \
WINTRUST_F
ree(action.pwszFunctionName);
f
ree(action.pwszDLLName); \
f
ree(action.pwszFunctionName);
WINTRUST_FREEREGENTRY
(
SoftpubInitialization
);
WINTRUST_FREEREGENTRY
(
SoftpubMessage
);
...
...
@@ -383,11 +381,11 @@ static LONG WINTRUST_WriteSingleUsageEntry(LPCSTR OID,
/* Turn OID into a wide-character string */
Len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
OID
,
-
1
,
NULL
,
0
);
OIDW
=
WINTRUST_A
lloc
(
Len
*
sizeof
(
WCHAR
)
);
OIDW
=
ma
lloc
(
Len
*
sizeof
(
WCHAR
)
);
MultiByteToWideChar
(
CP_ACP
,
0
,
OID
,
-
1
,
OIDW
,
Len
);
/* Allocate the needed space for UsageKey */
UsageKey
=
WINTRUST_Alloc
((
lstrlenW
(
Trust
)
+
lstrlenW
(
Usages
)
+
Len
)
*
sizeof
(
WCHAR
));
UsageKey
=
malloc
((
wcslen
(
Trust
)
+
wcslen
(
Usages
)
+
Len
)
*
sizeof
(
WCHAR
));
/* Create the key string */
lstrcpyW
(
UsageKey
,
Trust
);
lstrcatW
(
UsageKey
,
Usages
);
...
...
@@ -402,8 +400,8 @@ static LONG WINTRUST_WriteSingleUsageEntry(LPCSTR OID,
}
RegCloseKey
(
Key
);
WINTRUST_F
ree
(
OIDW
);
WINTRUST_F
ree
(
UsageKey
);
f
ree
(
OIDW
);
f
ree
(
UsageKey
);
return
Res
;
}
...
...
@@ -601,8 +599,7 @@ static BOOL WINTRUST_RegisterHttpsProv(void)
ProvInfo
.
sTestPolicyProvider
=
NullCTRE
;
/* No diagnostic policy */
ProvInfo
.
sCleanupProvider
=
SoftpubCleanup
;
DefUsage
.
pwszDllName
=
WINTRUST_Alloc
(
sizeof
(
SP_POLICY_PROVIDER_DLL_NAME
));
lstrcpyW
(
DefUsage
.
pwszDllName
,
SP_POLICY_PROVIDER_DLL_NAME
);
DefUsage
.
pwszDllName
=
wcsdup
(
SP_POLICY_PROVIDER_DLL_NAME
);
if
(
!
WintrustAddDefaultForUsage
(
szOID_PKIX_KP_SERVER_AUTH
,
&
DefUsage
))
RegisteredOK
=
FALSE
;
...
...
@@ -613,7 +610,7 @@ static BOOL WINTRUST_RegisterHttpsProv(void)
if
(
!
WintrustAddDefaultForUsage
(
szOID_SGC_NETSCAPE
,
&
DefUsage
))
RegisteredOK
=
FALSE
;
WINTRUST_F
ree
(
DefUsage
.
pwszDllName
);
f
ree
(
DefUsage
.
pwszDllName
);
if
(
!
WintrustAddActionID
(
&
ProvGUID
,
0
,
&
ProvInfo
))
RegisteredOK
=
FALSE
;
...
...
@@ -762,26 +759,26 @@ BOOL WINAPI WintrustAddDefaultForUsage(const char *pszUsageOID,
WCHAR
*
CallbackW
;
Len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
psDefUsage
->
pwszLoadCallbackDataFunctionName
,
-
1
,
NULL
,
0
);
CallbackW
=
WINTRUST_A
lloc
(
Len
*
sizeof
(
WCHAR
)
);
CallbackW
=
ma
lloc
(
Len
*
sizeof
(
WCHAR
)
);
MultiByteToWideChar
(
CP_ACP
,
0
,
psDefUsage
->
pwszLoadCallbackDataFunctionName
,
-
1
,
CallbackW
,
Len
);
Res
=
WINTRUST_WriteSingleUsageEntry
(
pszUsageOID
,
CBAlloc
,
CallbackW
);
if
(
Res
!=
ERROR_SUCCESS
)
WriteUsageError
=
Res
;
WINTRUST_F
ree
(
CallbackW
);
f
ree
(
CallbackW
);
}
if
(
psDefUsage
->
pwszFreeCallbackDataFunctionName
)
{
WCHAR
*
CallbackW
;
Len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
psDefUsage
->
pwszFreeCallbackDataFunctionName
,
-
1
,
NULL
,
0
);
CallbackW
=
WINTRUST_A
lloc
(
Len
*
sizeof
(
WCHAR
)
);
CallbackW
=
ma
lloc
(
Len
*
sizeof
(
WCHAR
)
);
MultiByteToWideChar
(
CP_ACP
,
0
,
psDefUsage
->
pwszFreeCallbackDataFunctionName
,
-
1
,
CallbackW
,
Len
);
Res
=
WINTRUST_WriteSingleUsageEntry
(
pszUsageOID
,
CBFree
,
CallbackW
);
if
(
Res
!=
ERROR_SUCCESS
)
WriteUsageError
=
Res
;
WINTRUST_F
ree
(
CallbackW
);
f
ree
(
CallbackW
);
}
WINTRUST_Guid2Wstr
(
psDefUsage
->
pgActionID
,
GuidString
);
...
...
@@ -852,6 +849,16 @@ static struct provider_cache_entry
*
provider_cache
;
static
unsigned
int
provider_cache_size
;
static
void
*
WINAPI
WINTRUST_Alloc
(
DWORD
cb
)
{
return
calloc
(
1
,
cb
);
}
static
void
WINAPI
WINTRUST_Free
(
void
*
p
)
{
free
(
p
);
}
/***********************************************************************
* WintrustLoadFunctionPointers (WINTRUST.@)
*/
...
...
@@ -951,10 +958,9 @@ static BOOL WINTRUST_SIPPAddProvider(GUID* Subject, WCHAR* MagicNumber)
/* Clear and initialize the structure */
memset
(
&
NewProv
,
0
,
sizeof
(
SIP_ADD_NEWPROVIDER
));
NewProv
.
cbStruct
=
sizeof
(
SIP_ADD_NEWPROVIDER
);
NewProv
.
pwszDLLFileName
=
WINTRUST_Alloc
(
sizeof
(
SP_POLICY_PROVIDER_DLL_NAME
)
);
NewProv
.
pwszDLLFileName
=
wcsdup
(
SP_POLICY_PROVIDER_DLL_NAME
);
/* Fill the structure */
NewProv
.
pgSubject
=
Subject
;
lstrcpyW
(
NewProv
.
pwszDLLFileName
,
SP_POLICY_PROVIDER_DLL_NAME
);
NewProv
.
pwszMagicNumber
=
MagicNumber
;
NewProv
.
pwszIsFunctionName
=
NULL
;
NewProv
.
pwszGetFuncName
=
CryptSIPGetSignedDataMsg
;
...
...
@@ -967,8 +973,8 @@ static BOOL WINTRUST_SIPPAddProvider(GUID* Subject, WCHAR* MagicNumber)
Ret
=
CryptSIPAddProvider
(
&
NewProv
);
WINTRUST_F
ree
(
NewProv
.
pwszDLLFileName
);
f
ree
(
NewProv
.
pwszDLLFileName
);
return
Ret
;
}
...
...
dlls/wintrust/softpub.c
View file @
6db69d02
...
...
@@ -213,7 +213,7 @@ static BOOL hash_file_data( HANDLE file, DWORD start, DWORD end, HCRYPTHASH hash
{
DWORD
bytes_read
,
size
=
end
-
start
;
DWORD
buffer_size
=
min
(
size
,
1024
*
1024
);
BYTE
*
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
buffer_size
);
BYTE
*
buffer
=
malloc
(
buffer_size
);
if
(
!
buffer
)
return
FALSE
;
SetFilePointer
(
file
,
start
,
NULL
,
FILE_BEGIN
);
...
...
@@ -224,7 +224,7 @@ static BOOL hash_file_data( HANDLE file, DWORD start, DWORD end, HCRYPTHASH hash
if
(
!
CryptHashData
(
hash
,
buffer
,
bytes_read
,
0
))
break
;
size
-=
bytes_read
;
}
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
free
(
buffer
);
return
!
size
;
}
...
...
dlls/wintrust/wintrust_main.c
View file @
6db69d02
...
...
@@ -36,24 +36,6 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
wintrust
);
/* Utility functions */
void
*
WINAPI
WINTRUST_Alloc
(
DWORD
cb
)
{
return
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
cb
);
}
static
void
*
WINTRUST_ReAlloc
(
void
*
ptr
,
DWORD
cb
)
__WINE_ALLOC_SIZE
(
2
);
static
void
*
WINTRUST_ReAlloc
(
void
*
ptr
,
DWORD
cb
)
{
return
HeapReAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
ptr
,
cb
);
}
void
WINAPI
WINTRUST_Free
(
void
*
p
)
{
HeapFree
(
GetProcessHeap
(),
0
,
p
);
}
/***********************************************************************
* TrustIsCertificateSelfSigned (WINTRUST.@)
*/
...
...
@@ -200,23 +182,22 @@ static CRYPT_PROVIDER_DATA *WINTRUST_AllocateProviderData(void)
{
CRYPT_PROVIDER_DATA
*
provData
;
provData
=
WINTRUST_Alloc
(
sizeof
(
CRYPT_PROVIDER_DATA
));
provData
=
calloc
(
1
,
sizeof
(
CRYPT_PROVIDER_DATA
));
if
(
!
provData
)
goto
oom
;
provData
->
cbStruct
=
sizeof
(
CRYPT_PROVIDER_DATA
);
provData
->
padwTrustStepErrors
=
WINTRUST_Alloc
(
TRUSTERROR_MAX_STEPS
*
sizeof
(
DWORD
));
provData
->
padwTrustStepErrors
=
calloc
(
TRUSTERROR_MAX_STEPS
,
sizeof
(
DWORD
));
if
(
!
provData
->
padwTrustStepErrors
)
goto
oom
;
provData
->
cdwTrustStepErrors
=
TRUSTERROR_MAX_STEPS
;
provData
->
pPDSip
=
WINTRUST_Alloc
(
sizeof
(
PROVDATA_SIP
));
provData
->
pPDSip
=
calloc
(
1
,
sizeof
(
PROVDATA_SIP
));
if
(
!
provData
->
pPDSip
)
goto
oom
;
provData
->
pPDSip
->
cbStruct
=
sizeof
(
PROVDATA_SIP
);
provData
->
psPfns
=
WINTRUST_Alloc
(
sizeof
(
CRYPT_PROVIDER_FUNCTIONS
));
provData
->
psPfns
=
calloc
(
1
,
sizeof
(
CRYPT_PROVIDER_FUNCTIONS
));
if
(
!
provData
->
psPfns
)
goto
oom
;
provData
->
psPfns
->
cbStruct
=
sizeof
(
CRYPT_PROVIDER_FUNCTIONS
);
...
...
@@ -225,10 +206,10 @@ static CRYPT_PROVIDER_DATA *WINTRUST_AllocateProviderData(void)
oom:
if
(
provData
)
{
WINTRUST_F
ree
(
provData
->
padwTrustStepErrors
);
WINTRUST_F
ree
(
provData
->
pPDSip
);
WINTRUST_F
ree
(
provData
->
psPfns
);
WINTRUST_F
ree
(
provData
);
f
ree
(
provData
->
padwTrustStepErrors
);
f
ree
(
provData
->
pPDSip
);
f
ree
(
provData
->
psPfns
);
f
ree
(
provData
);
}
return
NULL
;
}
...
...
@@ -309,10 +290,10 @@ static LONG WINTRUST_DefaultVerify(HWND hwnd, GUID *actionID,
goto
done
;
error:
WINTRUST_F
ree
(
provData
->
padwTrustStepErrors
);
WINTRUST_F
ree
(
provData
->
pPDSip
);
WINTRUST_F
ree
(
provData
->
psPfns
);
WINTRUST_F
ree
(
provData
);
f
ree
(
provData
->
padwTrustStepErrors
);
f
ree
(
provData
->
pPDSip
);
f
ree
(
provData
->
psPfns
);
f
ree
(
provData
);
done:
TRACE
(
"returning %08lx
\n
"
,
err
);
...
...
@@ -332,10 +313,10 @@ static LONG WINTRUST_DefaultClose(HWND hwnd, GUID *actionID,
if
(
provData
->
psPfns
->
pfnCleanupPolicy
)
err
=
provData
->
psPfns
->
pfnCleanupPolicy
(
provData
);
WINTRUST_F
ree
(
provData
->
padwTrustStepErrors
);
WINTRUST_F
ree
(
provData
->
pPDSip
);
WINTRUST_F
ree
(
provData
->
psPfns
);
WINTRUST_F
ree
(
provData
);
f
ree
(
provData
->
padwTrustStepErrors
);
f
ree
(
provData
->
pPDSip
);
f
ree
(
provData
->
psPfns
);
f
ree
(
provData
);
data
->
hWVTStateData
=
NULL
;
}
TRACE
(
"returning %08lx
\n
"
,
err
);
...
...
@@ -500,10 +481,10 @@ static LONG WINTRUST_CertVerify(HWND hwnd, GUID *actionID,
goto
done
;
error:
WINTRUST_F
ree
(
provData
->
padwTrustStepErrors
);
WINTRUST_F
ree
(
provData
->
pPDSip
);
WINTRUST_F
ree
(
provData
->
psPfns
);
WINTRUST_F
ree
(
provData
);
f
ree
(
provData
->
padwTrustStepErrors
);
f
ree
(
provData
->
pPDSip
);
f
ree
(
provData
->
psPfns
);
f
ree
(
provData
);
done:
TRACE
(
"returning %08lx
\n
"
,
err
);
...
...
@@ -852,7 +833,7 @@ static BOOL WINAPI WINTRUST_enumUsages(PCCRYPT_OID_INFO pInfo, void *pvArg)
if
(
!*
usages
)
{
cUsages
=
0
;
*
usages
=
WINTRUST_A
lloc
(
2
*
sizeof
(
PCCRYPT_OID_INFO
));
*
usages
=
ma
lloc
(
2
*
sizeof
(
PCCRYPT_OID_INFO
));
}
else
{
...
...
@@ -863,8 +844,7 @@ static BOOL WINAPI WINTRUST_enumUsages(PCCRYPT_OID_INFO pInfo, void *pvArg)
*/
for
(
cUsages
=
0
,
ptr
=
*
usages
;
*
ptr
;
ptr
++
,
cUsages
++
)
;
*
usages
=
WINTRUST_ReAlloc
(
*
usages
,
(
cUsages
+
2
)
*
sizeof
(
PCCRYPT_OID_INFO
));
*
usages
=
realloc
(
*
usages
,
(
cUsages
+
2
)
*
sizeof
(
PCCRYPT_OID_INFO
));
}
if
(
*
usages
)
{
...
...
@@ -916,7 +896,7 @@ BOOL WINAPI WTHelperGetKnownUsages(DWORD action, PCCRYPT_OID_INFO **usages)
}
else
if
(
action
==
2
)
{
WINTRUST_F
ree
(
*
usages
);
f
ree
(
*
usages
);
*
usages
=
NULL
;
ret
=
TRUE
;
}
...
...
@@ -1003,14 +983,7 @@ BOOL WINAPI WINTRUST_AddStore(CRYPT_PROVIDER_DATA *data, HCERTSTORE store)
TRACE
(
"(%p, %p)
\n
"
,
data
,
store
);
if
(
data
->
chStores
)
data
->
pahStores
=
WINTRUST_ReAlloc
(
data
->
pahStores
,
(
data
->
chStores
+
1
)
*
sizeof
(
HCERTSTORE
));
else
{
data
->
pahStores
=
WINTRUST_Alloc
(
sizeof
(
HCERTSTORE
));
data
->
chStores
=
0
;
}
data
->
pahStores
=
realloc
(
data
->
pahStores
,
(
data
->
chStores
+
1
)
*
sizeof
(
HCERTSTORE
));
if
(
data
->
pahStores
)
{
data
->
pahStores
[
data
->
chStores
++
]
=
CertDuplicateStore
(
store
);
...
...
@@ -1039,14 +1012,8 @@ BOOL WINAPI WINTRUST_AddSgnr(CRYPT_PROVIDER_DATA *data,
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
if
(
data
->
csSigners
)
data
->
pasSigners
=
WINTRUST_ReAlloc
(
data
->
pasSigners
,
(
data
->
csSigners
+
1
)
*
sizeof
(
CRYPT_PROVIDER_SGNR
));
else
{
data
->
pasSigners
=
WINTRUST_Alloc
(
sizeof
(
CRYPT_PROVIDER_SGNR
));
data
->
csSigners
=
0
;
}
data
->
pasSigners
=
realloc
(
data
->
pasSigners
,
(
data
->
csSigners
+
1
)
*
sizeof
(
CRYPT_PROVIDER_SGNR
));
if
(
data
->
pasSigners
)
{
if
(
idxSigner
<
data
->
csSigners
)
...
...
@@ -1088,17 +1055,10 @@ BOOL WINAPI WINTRUST_AddCert(CRYPT_PROVIDER_DATA *data, DWORD idxSigner,
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
if
(
data
->
pasSigners
[
idxSigner
].
csCertChain
)
data
->
pasSigners
[
idxSigner
].
pasCertChain
=
WINTRUST_ReAlloc
(
data
->
pasSigners
[
idxSigner
].
pasCertChain
,
(
data
->
pasSigners
[
idxSigner
].
csCertChain
+
1
)
*
sizeof
(
CRYPT_PROVIDER_CERT
));
else
{
data
->
pasSigners
[
idxSigner
].
pasCertChain
=
WINTRUST_Alloc
(
sizeof
(
CRYPT_PROVIDER_CERT
));
data
->
pasSigners
[
idxSigner
].
csCertChain
=
0
;
}
data
->
pasSigners
[
idxSigner
].
pasCertChain
=
realloc
(
data
->
pasSigners
[
idxSigner
].
pasCertChain
,
(
data
->
pasSigners
[
idxSigner
].
csCertChain
+
1
)
*
sizeof
(
CRYPT_PROVIDER_CERT
));
if
(
data
->
pasSigners
[
idxSigner
].
pasCertChain
)
{
CRYPT_PROVIDER_CERT
*
cert
=
&
data
->
pasSigners
[
idxSigner
].
pasCertChain
[
...
...
@@ -1127,14 +1087,8 @@ BOOL WINAPI WINTRUST_AddPrivData(CRYPT_PROVIDER_DATA *data,
WARN
(
"invalid struct size
\n
"
);
return
FALSE
;
}
if
(
data
->
csProvPrivData
)
data
->
pasProvPrivData
=
WINTRUST_ReAlloc
(
data
->
pasProvPrivData
,
(
data
->
csProvPrivData
+
1
)
*
sizeof
(
CRYPT_PROVIDER_SGNR
));
else
{
data
->
pasProvPrivData
=
WINTRUST_Alloc
(
sizeof
(
CRYPT_PROVIDER_SGNR
));
data
->
csProvPrivData
=
0
;
}
data
->
pasProvPrivData
=
realloc
(
data
->
pasProvPrivData
,
(
data
->
csProvPrivData
+
1
)
*
sizeof
(
CRYPT_PROVIDER_SGNR
));
if
(
data
->
pasProvPrivData
)
{
DWORD
i
;
...
...
dlls/wintrust/wintrust_priv.h
View file @
6db69d02
...
...
@@ -18,9 +18,6 @@
#ifndef __WINTRUST_PRIV_H__
#define __WINTRUST_PRIV_H__
void
WINAPI
WINTRUST_Free
(
void
*
p
)
DECLSPEC_HIDDEN
;
void
*
WINAPI
WINTRUST_Alloc
(
DWORD
cb
)
__WINE_ALLOC_SIZE
(
1
)
__WINE_DEALLOC
(
WINTRUST_Free
)
__WINE_MALLOC
DECLSPEC_HIDDEN
;
BOOL
WINAPI
WINTRUST_AddStore
(
CRYPT_PROVIDER_DATA
*
data
,
HCERTSTORE
store
)
DECLSPEC_HIDDEN
;
BOOL
WINAPI
WINTRUST_AddSgnr
(
CRYPT_PROVIDER_DATA
*
data
,
BOOL
fCounterSigner
,
DWORD
idxSigner
,
CRYPT_PROVIDER_SGNR
*
sgnr
)
DECLSPEC_HIDDEN
;
...
...
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