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
1fb28509
Commit
1fb28509
authored
Mar 30, 2022
by
Hans Leidekker
Committed by
Alexandre Julliard
Mar 30, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Consistently use CryptMemAlloc/Free().
Signed-off-by:
Hans Leidekker
<
hans@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
dd91e541
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
24 deletions
+21
-24
cert.c
dlls/crypt32/cert.c
+6
-6
chain.c
dlls/crypt32/chain.c
+2
-2
msg.c
dlls/crypt32/msg.c
+2
-2
pfx.c
dlls/crypt32/pfx.c
+5
-7
rootstore.c
dlls/crypt32/rootstore.c
+4
-5
serialize.c
dlls/crypt32/serialize.c
+2
-2
No files found.
dlls/crypt32/cert.c
View file @
1fb28509
...
@@ -677,7 +677,7 @@ static BOOL CertContext_SetKeyProvInfoProperty(CONTEXT_PROPERTY_LIST *properties
...
@@ -677,7 +677,7 @@ static BOOL CertContext_SetKeyProvInfoProperty(CONTEXT_PROPERTY_LIST *properties
for
(
i
=
0
;
i
<
info
->
cProvParam
;
i
++
)
for
(
i
=
0
;
i
<
info
->
cProvParam
;
i
++
)
size
+=
sizeof
(
CRYPT_KEY_PROV_PARAM
)
+
info
->
rgProvParam
[
i
].
cbData
;
size
+=
sizeof
(
CRYPT_KEY_PROV_PARAM
)
+
info
->
rgProvParam
[
i
].
cbData
;
prop
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
prop
=
CryptMemAlloc
(
size
);
if
(
!
prop
)
if
(
!
prop
)
{
{
SetLastError
(
ERROR_OUTOFMEMORY
);
SetLastError
(
ERROR_OUTOFMEMORY
);
...
@@ -687,7 +687,7 @@ static BOOL CertContext_SetKeyProvInfoProperty(CONTEXT_PROPERTY_LIST *properties
...
@@ -687,7 +687,7 @@ static BOOL CertContext_SetKeyProvInfoProperty(CONTEXT_PROPERTY_LIST *properties
copy_KeyProvInfoProperty
(
info
,
prop
);
copy_KeyProvInfoProperty
(
info
,
prop
);
ret
=
ContextPropertyList_SetProperty
(
properties
,
CERT_KEY_PROV_INFO_PROP_ID
,
(
const
BYTE
*
)
prop
,
size
);
ret
=
ContextPropertyList_SetProperty
(
properties
,
CERT_KEY_PROV_INFO_PROP_ID
,
(
const
BYTE
*
)
prop
,
size
);
HeapFree
(
GetProcessHeap
(),
0
,
prop
);
CryptMemFree
(
prop
);
return
ret
;
return
ret
;
}
}
...
@@ -865,7 +865,7 @@ static BOOL CRYPT_AcquirePrivateKeyFromProvInfo(PCCERT_CONTEXT pCert, DWORD dwFl
...
@@ -865,7 +865,7 @@ static BOOL CRYPT_AcquirePrivateKeyFromProvInfo(PCCERT_CONTEXT pCert, DWORD dwFl
CERT_KEY_PROV_INFO_PROP_ID
,
0
,
&
size
);
CERT_KEY_PROV_INFO_PROP_ID
,
0
,
&
size
);
if
(
ret
)
if
(
ret
)
{
{
info
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
info
=
CryptMemAlloc
(
size
);
if
(
info
)
if
(
info
)
{
{
ret
=
CertGetCertificateContextProperty
(
pCert
,
ret
=
CertGetCertificateContextProperty
(
pCert
,
...
@@ -901,7 +901,7 @@ static BOOL CRYPT_AcquirePrivateKeyFromProvInfo(PCCERT_CONTEXT pCert, DWORD dwFl
...
@@ -901,7 +901,7 @@ static BOOL CRYPT_AcquirePrivateKeyFromProvInfo(PCCERT_CONTEXT pCert, DWORD dwFl
SetLastError
(
CRYPT_E_NO_KEY_PROPERTY
);
SetLastError
(
CRYPT_E_NO_KEY_PROPERTY
);
}
}
if
(
allocated
)
if
(
allocated
)
HeapFree
(
GetProcessHeap
(),
0
,
info
);
CryptMemFree
(
info
);
return
ret
;
return
ret
;
}
}
...
@@ -953,7 +953,7 @@ BOOL WINAPI CryptAcquireCertificatePrivateKey(PCCERT_CONTEXT pCert,
...
@@ -953,7 +953,7 @@ BOOL WINAPI CryptAcquireCertificatePrivateKey(PCCERT_CONTEXT pCert,
if
(
ret
)
if
(
ret
)
{
{
info
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
info
=
CryptMemAlloc
(
size
);
ret
=
CertGetCertificateContextProperty
(
pCert
,
ret
=
CertGetCertificateContextProperty
(
pCert
,
CERT_KEY_PROV_INFO_PROP_ID
,
info
,
&
size
);
CERT_KEY_PROV_INFO_PROP_ID
,
info
,
&
size
);
if
(
ret
)
if
(
ret
)
...
@@ -1003,7 +1003,7 @@ BOOL WINAPI CryptAcquireCertificatePrivateKey(PCCERT_CONTEXT pCert,
...
@@ -1003,7 +1003,7 @@ BOOL WINAPI CryptAcquireCertificatePrivateKey(PCCERT_CONTEXT pCert,
}
}
}
}
}
}
HeapFree
(
GetProcessHeap
(),
0
,
info
);
CryptMemFree
(
info
);
if
(
cert_in_store
)
if
(
cert_in_store
)
CertFreeCertificateContext
(
cert_in_store
);
CertFreeCertificateContext
(
cert_in_store
);
return
ret
;
return
ret
;
...
...
dlls/crypt32/chain.c
View file @
1fb28509
...
@@ -2007,7 +2007,7 @@ static PCCERT_CONTEXT CRYPT_FindIssuer(const CertificateChainEngine *engine, con
...
@@ -2007,7 +2007,7 @@ static PCCERT_CONTEXT CRYPT_FindIssuer(const CertificateChainEngine *engine, con
if
(
!
res
)
if
(
!
res
)
return
NULL
;
return
NULL
;
urls
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
urls
=
CryptMemAlloc
(
size
);
if
(
!
urls
)
if
(
!
urls
)
return
NULL
;
return
NULL
;
...
@@ -2045,7 +2045,7 @@ static PCCERT_CONTEXT CRYPT_FindIssuer(const CertificateChainEngine *engine, con
...
@@ -2045,7 +2045,7 @@ static PCCERT_CONTEXT CRYPT_FindIssuer(const CertificateChainEngine *engine, con
}
}
}
}
HeapFree
(
GetProcessHeap
(),
0
,
urls
);
CryptMemFree
(
urls
);
return
issuer
;
return
issuer
;
}
}
...
...
dlls/crypt32/msg.c
View file @
1fb28509
...
@@ -1666,12 +1666,12 @@ static BOOL CRYPT_ExportEncryptedKey(CMSG_CONTENT_ENCRYPT_INFO *info, DWORD i,
...
@@ -1666,12 +1666,12 @@ static BOOL CRYPT_ExportEncryptedKey(CMSG_CONTENT_ENCRYPT_INFO *info, DWORD i,
static
LPVOID
WINAPI
mem_alloc
(
size_t
size
)
static
LPVOID
WINAPI
mem_alloc
(
size_t
size
)
{
{
return
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
return
CryptMemAlloc
(
size
);
}
}
static
VOID
WINAPI
mem_free
(
LPVOID
pv
)
static
VOID
WINAPI
mem_free
(
LPVOID
pv
)
{
{
HeapFree
(
GetProcessHeap
(),
0
,
pv
);
CryptMemFree
(
pv
);
}
}
...
...
dlls/crypt32/pfx.c
View file @
1fb28509
...
@@ -17,7 +17,6 @@
...
@@ -17,7 +17,6 @@
*/
*/
#include <stdarg.h>
#include <stdarg.h>
#include <stdlib.h>
#include "ntstatus.h"
#include "ntstatus.h"
#define WIN32_NO_STATUS
#define WIN32_NO_STATUS
...
@@ -28,7 +27,6 @@
...
@@ -28,7 +27,6 @@
#include "crypt32_private.h"
#include "crypt32_private.h"
#include "wine/debug.h"
#include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
crypt
);
WINE_DEFAULT_DEBUG_CHANNEL
(
crypt
);
...
@@ -55,17 +53,17 @@ static HCRYPTPROV import_key( cert_store_data_t data, DWORD flags )
...
@@ -55,17 +53,17 @@ static HCRYPTPROV import_key( cert_store_data_t data, DWORD flags )
}
}
}
}
params
.
buf
=
key
=
ma
lloc
(
size
);
params
.
buf
=
key
=
CryptMemA
lloc
(
size
);
if
(
CRYPT32_CALL
(
import_store_key
,
&
params
)
||
if
(
CRYPT32_CALL
(
import_store_key
,
&
params
)
||
!
CryptImportKey
(
prov
,
key
,
size
,
0
,
flags
&
CRYPT_EXPORTABLE
,
&
cryptkey
))
!
CryptImportKey
(
prov
,
key
,
size
,
0
,
flags
&
CRYPT_EXPORTABLE
,
&
cryptkey
))
{
{
WARN
(
"CryptImportKey failed %08lx
\n
"
,
GetLastError
()
);
WARN
(
"CryptImportKey failed %08lx
\n
"
,
GetLastError
()
);
CryptReleaseContext
(
prov
,
0
);
CryptReleaseContext
(
prov
,
0
);
f
ree
(
key
);
CryptMemF
ree
(
key
);
return
0
;
return
0
;
}
}
CryptDestroyKey
(
cryptkey
);
CryptDestroyKey
(
cryptkey
);
f
ree
(
key
);
CryptMemF
ree
(
key
);
return
prov
;
return
prov
;
}
}
...
@@ -177,10 +175,10 @@ HCERTSTORE WINAPI PFXImportCertStore( CRYPT_DATA_BLOB *pfx, const WCHAR *passwor
...
@@ -177,10 +175,10 @@ HCERTSTORE WINAPI PFXImportCertStore( CRYPT_DATA_BLOB *pfx, const WCHAR *passwor
struct
import_store_cert_params
import_params
=
{
data
,
i
,
NULL
,
&
size
};
struct
import_store_cert_params
import_params
=
{
data
,
i
,
NULL
,
&
size
};
if
(
CRYPT32_CALL
(
import_store_cert
,
&
import_params
)
!=
STATUS_BUFFER_TOO_SMALL
)
break
;
if
(
CRYPT32_CALL
(
import_store_cert
,
&
import_params
)
!=
STATUS_BUFFER_TOO_SMALL
)
break
;
import_params
.
buf
=
cert
=
ma
lloc
(
size
);
import_params
.
buf
=
cert
=
CryptMemA
lloc
(
size
);
if
(
!
CRYPT32_CALL
(
import_store_cert
,
&
import_params
))
if
(
!
CRYPT32_CALL
(
import_store_cert
,
&
import_params
))
ctx
=
CertCreateContext
(
CERT_STORE_CERTIFICATE_CONTEXT
,
X509_ASN_ENCODING
,
cert
,
size
,
0
,
NULL
);
ctx
=
CertCreateContext
(
CERT_STORE_CERTIFICATE_CONTEXT
,
X509_ASN_ENCODING
,
cert
,
size
,
0
,
NULL
);
f
ree
(
cert
);
CryptMemF
ree
(
cert
);
if
(
!
ctx
)
if
(
!
ctx
)
{
{
WARN
(
"CertCreateContext failed %08lx
\n
"
,
GetLastError
()
);
WARN
(
"CertCreateContext failed %08lx
\n
"
,
GetLastError
()
);
...
...
dlls/crypt32/rootstore.c
View file @
1fb28509
...
@@ -18,7 +18,6 @@
...
@@ -18,7 +18,6 @@
#include <stdarg.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include "ntstatus.h"
#include "ntstatus.h"
#define WIN32_NO_STATUS
#define WIN32_NO_STATUS
...
@@ -622,19 +621,19 @@ static void read_trusted_roots_from_known_locations(HCERTSTORE store)
...
@@ -622,19 +621,19 @@ static void read_trusted_roots_from_known_locations(HCERTSTORE store)
if
(
from
)
if
(
from
)
{
{
params
.
buffer
=
ma
lloc
(
params
.
size
);
params
.
buffer
=
CryptMemA
lloc
(
params
.
size
);
while
(
!
CRYPT32_CALL
(
enum_root_certs
,
&
params
))
while
(
!
CRYPT32_CALL
(
enum_root_certs
,
&
params
))
{
{
if
(
needed
>
params
.
size
)
if
(
needed
>
params
.
size
)
{
{
f
ree
(
params
.
buffer
);
CryptMemF
ree
(
params
.
buffer
);
params
.
buffer
=
ma
lloc
(
needed
);
params
.
buffer
=
CryptMemA
lloc
(
needed
);
params
.
size
=
needed
;
params
.
size
=
needed
;
}
}
else
CertAddEncodedCertificateToStore
(
from
,
X509_ASN_ENCODING
,
params
.
buffer
,
needed
,
else
CertAddEncodedCertificateToStore
(
from
,
X509_ASN_ENCODING
,
params
.
buffer
,
needed
,
CERT_STORE_ADD_NEW
,
NULL
);
CERT_STORE_ADD_NEW
,
NULL
);
}
}
f
ree
(
params
.
buffer
);
CryptMemF
ree
(
params
.
buffer
);
check_and_store_certs
(
from
,
store
);
check_and_store_certs
(
from
,
store
);
}
}
CertCloseStore
(
from
,
0
);
CertCloseStore
(
from
,
0
);
...
...
dlls/crypt32/serialize.c
View file @
1fb28509
...
@@ -72,7 +72,7 @@ static DWORD serialize_KeyProvInfoProperty(const CRYPT_KEY_PROV_INFO *info, stru
...
@@ -72,7 +72,7 @@ static DWORD serialize_KeyProvInfoProperty(const CRYPT_KEY_PROV_INFO *info, stru
if
(
!
ret
)
return
size
;
if
(
!
ret
)
return
size
;
store
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
store
=
CryptMemAlloc
(
size
);
if
(
!
store
)
return
0
;
if
(
!
store
)
return
0
;
param
=
(
struct
store_CRYPT_KEY_PROV_PARAM
*
)(
store
+
1
);
param
=
(
struct
store_CRYPT_KEY_PROV_PARAM
*
)(
store
+
1
);
...
@@ -331,7 +331,7 @@ static DWORD read_serialized_KeyProvInfoProperty(const struct store_CRYPT_KEY_PR
...
@@ -331,7 +331,7 @@ static DWORD read_serialized_KeyProvInfoProperty(const struct store_CRYPT_KEY_PR
for
(
i
=
0
;
i
<
store
->
cProvParam
;
i
++
)
for
(
i
=
0
;
i
<
store
->
cProvParam
;
i
++
)
size
+=
sizeof
(
CRYPT_KEY_PROV_PARAM
)
+
param
[
i
].
cbData
;
size
+=
sizeof
(
CRYPT_KEY_PROV_PARAM
)
+
param
[
i
].
cbData
;
info
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
info
=
CryptMemAlloc
(
size
);
if
(
!
info
)
if
(
!
info
)
{
{
SetLastError
(
ERROR_OUTOFMEMORY
);
SetLastError
(
ERROR_OUTOFMEMORY
);
...
...
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