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
2d6d002b
Commit
2d6d002b
authored
Oct 28, 2005
by
Juan Lang
Committed by
Alexandre Julliard
Oct 28, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use CryptMem functions for internal memory allocation.
parent
717a4eb6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
41 deletions
+41
-41
cert.c
dlls/crypt32/cert.c
+0
-0
encode.c
dlls/crypt32/encode.c
+22
-22
protectdata.c
dlls/crypt32/protectdata.c
+19
-19
No files found.
dlls/crypt32/cert.c
View file @
2d6d002b
This diff is collapsed.
Click to expand it.
dlls/crypt32/encode.c
View file @
2d6d002b
...
...
@@ -211,7 +211,7 @@ static char *CRYPT_GetKeyName(DWORD dwEncodingType, LPCSTR pszFuncName,
* format specifier that are removed by sprintf.
*/
len
=
sizeof
(
szEncodingTypeFmt
)
+
lstrlenA
(
pszFuncName
)
+
lstrlenA
(
oid
);
szKey
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
);
szKey
=
CryptMemAlloc
(
len
);
if
(
szKey
)
sprintf
(
szKey
,
szEncodingTypeFmt
,
dwEncodingType
,
pszFuncName
,
oid
);
return
szKey
;
...
...
@@ -255,7 +255,7 @@ BOOL WINAPI CryptRegisterOIDFunction(DWORD dwEncodingType, LPCSTR pszFuncName,
return
FALSE
;
r
=
RegCreateKeyA
(
HKEY_LOCAL_MACHINE
,
szKey
,
&
hKey
);
HeapFree
(
GetProcessHeap
(),
0
,
szKey
);
CryptMemFree
(
szKey
);
if
(
r
!=
ERROR_SUCCESS
)
return
FALSE
;
...
...
@@ -289,7 +289,7 @@ BOOL WINAPI CryptUnregisterOIDFunction(DWORD dwEncodingType, LPCSTR pszFuncName,
szKey
=
CRYPT_GetKeyName
(
dwEncodingType
,
pszFuncName
,
pszOID
);
rc
=
RegDeleteKeyA
(
HKEY_LOCAL_MACHINE
,
szKey
);
HeapFree
(
GetProcessHeap
(),
0
,
szKey
);
CryptMemFree
(
szKey
);
if
(
rc
)
SetLastError
(
rc
);
return
rc
?
FALSE
:
TRUE
;
...
...
@@ -318,7 +318,7 @@ BOOL WINAPI CryptGetOIDFunctionValue(DWORD dwEncodingType, LPCSTR pszFuncName,
szKey
=
CRYPT_GetKeyName
(
dwEncodingType
,
pszFuncName
,
pszOID
);
rc
=
RegOpenKeyA
(
HKEY_LOCAL_MACHINE
,
szKey
,
&
hKey
);
HeapFree
(
GetProcessHeap
(),
0
,
szKey
);
CryptMemFree
(
szKey
);
if
(
rc
)
SetLastError
(
rc
);
else
...
...
@@ -355,7 +355,7 @@ BOOL WINAPI CryptSetOIDFunctionValue(DWORD dwEncodingType, LPCSTR pszFuncName,
szKey
=
CRYPT_GetKeyName
(
dwEncodingType
,
pszFuncName
,
pszOID
);
rc
=
RegOpenKeyA
(
HKEY_LOCAL_MACHINE
,
szKey
,
&
hKey
);
HeapFree
(
GetProcessHeap
(),
0
,
szKey
);
CryptMemFree
(
szKey
);
if
(
rc
)
SetLastError
(
rc
);
else
...
...
@@ -390,14 +390,14 @@ static void *CRYPT_GetFunc(DWORD dwCertEncodingType, LPCSTR lpszStructType,
*
lib
=
NULL
;
r
=
RegOpenKeyA
(
HKEY_LOCAL_MACHINE
,
szKey
,
&
hKey
);
HeapFree
(
GetProcessHeap
(),
0
,
szKey
);
CryptMemFree
(
szKey
);
if
(
r
!=
ERROR_SUCCESS
)
return
NULL
;
RegQueryValueExA
(
hKey
,
"FuncName"
,
NULL
,
&
type
,
NULL
,
&
size
);
if
(
GetLastError
()
==
ERROR_MORE_DATA
&&
type
==
REG_SZ
)
{
funcName
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
funcName
=
CryptMemAlloc
(
size
);
RegQueryValueExA
(
hKey
,
"FuncName"
,
NULL
,
&
type
,
(
LPBYTE
)
funcName
,
&
size
);
}
...
...
@@ -406,7 +406,7 @@ static void *CRYPT_GetFunc(DWORD dwCertEncodingType, LPCSTR lpszStructType,
RegQueryValueExW
(
hKey
,
szDllName
,
NULL
,
&
type
,
NULL
,
&
size
);
if
(
GetLastError
()
==
ERROR_MORE_DATA
&&
type
==
REG_SZ
)
{
LPWSTR
dllName
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
LPWSTR
dllName
=
CryptMemAlloc
(
size
);
RegQueryValueExW
(
hKey
,
szDllName
,
NULL
,
&
type
,
(
LPBYTE
)
dllName
,
&
size
);
...
...
@@ -423,10 +423,10 @@ static void *CRYPT_GetFunc(DWORD dwCertEncodingType, LPCSTR lpszStructType,
*
lib
=
NULL
;
}
}
HeapFree
(
GetProcessHeap
(),
0
,
dllName
);
CryptMemFree
(
dllName
);
}
if
(
funcName
!=
szFuncName
)
HeapFree
(
GetProcessHeap
(),
0
,
(
char
*
)
funcName
);
CryptMemFree
(
(
char
*
)
funcName
);
TRACE
(
"returning %p
\n
"
,
ret
);
return
ret
;
}
...
...
@@ -1330,10 +1330,11 @@ static BOOL WINAPI CRYPT_AsnEncodeRdn(DWORD dwCertEncodingType, CERT_RDN *rdn,
ret
=
TRUE
;
if
(
rdn
->
cRDNAttr
)
{
blobs
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
rdn
->
cRDNAttr
*
sizeof
(
CRYPT_DER_BLOB
));
blobs
=
CryptMemAlloc
(
rdn
->
cRDNAttr
*
sizeof
(
CRYPT_DER_BLOB
));
if
(
!
blobs
)
ret
=
FALSE
;
else
memset
(
blobs
,
0
,
rdn
->
cRDNAttr
*
sizeof
(
CRYPT_DER_BLOB
));
}
for
(
i
=
0
;
ret
&&
i
<
rdn
->
cRDNAttr
;
i
++
)
{
...
...
@@ -1357,8 +1358,7 @@ static BOOL WINAPI CRYPT_AsnEncodeRdn(DWORD dwCertEncodingType, CERT_RDN *rdn,
{
for
(
i
=
0
;
ret
&&
i
<
rdn
->
cRDNAttr
;
i
++
)
{
blobs
[
i
].
pbData
=
HeapAlloc
(
GetProcessHeap
(),
0
,
blobs
[
i
].
cbData
);
blobs
[
i
].
pbData
=
CryptMemAlloc
(
blobs
[
i
].
cbData
);
if
(
!
blobs
[
i
].
pbData
)
ret
=
FALSE
;
else
...
...
@@ -1387,7 +1387,7 @@ static BOOL WINAPI CRYPT_AsnEncodeRdn(DWORD dwCertEncodingType, CERT_RDN *rdn,
if
(
blobs
)
{
for
(
i
=
0
;
i
<
rdn
->
cRDNAttr
;
i
++
)
HeapFree
(
GetProcessHeap
(),
0
,
blobs
[
i
].
pbData
);
CryptMemFree
(
blobs
[
i
].
pbData
);
}
}
__EXCEPT
(
page_fault
)
...
...
@@ -1396,7 +1396,7 @@ static BOOL WINAPI CRYPT_AsnEncodeRdn(DWORD dwCertEncodingType, CERT_RDN *rdn,
return
FALSE
;
}
__ENDTRY
HeapFree
(
GetProcessHeap
(),
0
,
blobs
);
CryptMemFree
(
blobs
);
return
ret
;
}
...
...
@@ -1866,7 +1866,7 @@ static BOOL WINAPI CRYPT_AsnEncodeBitsSwapBytes(DWORD dwCertEncodingType,
ret
=
TRUE
;
if
(
newBlob
.
cbData
)
{
newBlob
.
pbData
=
HeapAlloc
(
GetProcessHeap
(),
0
,
newBlob
.
cbData
);
newBlob
.
pbData
=
CryptMemAlloc
(
newBlob
.
cbData
);
if
(
newBlob
.
pbData
)
{
DWORD
i
;
...
...
@@ -1880,7 +1880,7 @@ static BOOL WINAPI CRYPT_AsnEncodeBitsSwapBytes(DWORD dwCertEncodingType,
if
(
ret
)
ret
=
CRYPT_AsnEncodeBits
(
dwCertEncodingType
,
lpszStructType
,
&
newBlob
,
dwFlags
,
pEncodePara
,
pbEncoded
,
pcbEncoded
);
HeapFree
(
GetProcessHeap
(),
0
,
newBlob
.
pbData
);
CryptMemFree
(
newBlob
.
pbData
);
}
__EXCEPT
(
page_fault
)
{
...
...
@@ -5547,7 +5547,7 @@ static BOOL WINAPI CRYPT_ExportRsaPublicKeyInfoEx(HCRYPTPROV hCryptProv,
ret
=
CryptExportKey
(
key
,
0
,
PUBLICKEYBLOB
,
0
,
NULL
,
&
keySize
);
if
(
ret
)
{
LPBYTE
pubKey
=
HeapAlloc
(
GetProcessHeap
(),
0
,
keySize
);
LPBYTE
pubKey
=
CryptMemAlloc
(
keySize
);
if
(
pubKey
)
{
...
...
@@ -5591,7 +5591,7 @@ static BOOL WINAPI CRYPT_ExportRsaPublicKeyInfoEx(HCRYPTPROV hCryptProv,
}
}
}
HeapFree
(
GetProcessHeap
(),
0
,
pubKey
);
CryptMemFree
(
pubKey
);
}
else
ret
=
FALSE
;
...
...
@@ -5656,7 +5656,7 @@ static BOOL WINAPI CRYPT_ImportRsaPublicKeyInfoEx(HCRYPTPROV hCryptProv,
pInfo
->
PublicKey
.
pbData
,
pInfo
->
PublicKey
.
cbData
,
0
,
NULL
,
&
pubKeySize
);
if
(
ret
)
{
LPBYTE
pubKey
=
HeapAlloc
(
GetProcessHeap
(),
0
,
pubKeySize
);
LPBYTE
pubKey
=
CryptMemAlloc
(
pubKeySize
);
if
(
pubKey
)
{
...
...
@@ -5666,7 +5666,7 @@ static BOOL WINAPI CRYPT_ImportRsaPublicKeyInfoEx(HCRYPTPROV hCryptProv,
if
(
ret
)
ret
=
CryptImportKey
(
hCryptProv
,
pubKey
,
pubKeySize
,
0
,
0
,
phKey
);
HeapFree
(
GetProcessHeap
(),
0
,
pubKey
);
CryptMemFree
(
pubKey
);
}
else
ret
=
FALSE
;
...
...
dlls/crypt32/protectdata.c
View file @
2d6d002b
...
...
@@ -196,7 +196,7 @@ BOOL unserialize_string(BYTE * ptr, DWORD *index, DWORD size,
return
FALSE
;
}
if
(
!
(
*
data
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
width
)))
if
(
!
(
*
data
=
CryptMemAlloc
(
len
*
width
)))
{
return
FALSE
;
}
...
...
@@ -538,19 +538,19 @@ void free_protect_data(struct protect_data_t * pInfo)
if
(
!
pInfo
)
return
;
if
(
pInfo
->
info0
.
pbData
)
HeapFree
(
GetProcessHeap
(),
0
,
pInfo
->
info0
.
pbData
);
CryptMemFree
(
pInfo
->
info0
.
pbData
);
if
(
pInfo
->
info1
.
pbData
)
HeapFree
(
GetProcessHeap
(),
0
,
pInfo
->
info1
.
pbData
);
CryptMemFree
(
pInfo
->
info1
.
pbData
);
if
(
pInfo
->
szDataDescr
)
HeapFree
(
GetProcessHeap
(),
0
,
pInfo
->
szDataDescr
);
CryptMemFree
(
pInfo
->
szDataDescr
);
if
(
pInfo
->
data0
.
pbData
)
HeapFree
(
GetProcessHeap
(),
0
,
pInfo
->
data0
.
pbData
);
CryptMemFree
(
pInfo
->
data0
.
pbData
);
if
(
pInfo
->
salt
.
pbData
)
HeapFree
(
GetProcessHeap
(),
0
,
pInfo
->
salt
.
pbData
);
CryptMemFree
(
pInfo
->
salt
.
pbData
);
if
(
pInfo
->
cipher
.
pbData
)
HeapFree
(
GetProcessHeap
(),
0
,
pInfo
->
cipher
.
pbData
);
CryptMemFree
(
pInfo
->
cipher
.
pbData
);
if
(
pInfo
->
fingerprint
.
pbData
)
HeapFree
(
GetProcessHeap
(),
0
,
pInfo
->
fingerprint
.
pbData
);
CryptMemFree
(
pInfo
->
fingerprint
.
pbData
);
}
/* copies a string into a data blob */
...
...
@@ -560,7 +560,7 @@ BYTE * convert_str_to_blob(char* str, DATA_BLOB* blob)
if
(
!
str
||
!
blob
)
return
NULL
;
blob
->
cbData
=
strlen
(
str
)
+
1
;
if
(
!
(
blob
->
pbData
=
HeapAlloc
(
GetProcessHeap
(),
0
,
blob
->
cbData
)))
if
(
!
(
blob
->
pbData
=
CryptMemAlloc
(
blob
->
cbData
)))
{
blob
->
cbData
=
0
;
}
...
...
@@ -598,7 +598,7 @@ BOOL fill_protect_data(struct protect_data_t * pInfo, LPCWSTR szDataDescr,
pInfo
->
null0
=
0x0000
;
if
((
pInfo
->
szDataDescr
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
dwStrLen
+
1
)
*
sizeof
(
WCHAR
))))
if
((
pInfo
->
szDataDescr
=
CryptMemAlloc
(
(
dwStrLen
+
1
)
*
sizeof
(
WCHAR
))))
{
memcpy
(
pInfo
->
szDataDescr
,
szDataDescr
,(
dwStrLen
+
1
)
*
sizeof
(
WCHAR
));
}
...
...
@@ -614,7 +614,7 @@ BOOL fill_protect_data(struct protect_data_t * pInfo, LPCWSTR szDataDescr,
/* allocate memory to hold a salt */
pInfo
->
salt
.
cbData
=
CRYPT32_PROTECTDATA_SALT_LEN
;
if
((
pInfo
->
salt
.
pbData
=
HeapAlloc
(
GetProcessHeap
(),
0
,
pInfo
->
salt
.
cbData
)))
if
((
pInfo
->
salt
.
pbData
=
CryptMemAlloc
(
pInfo
->
salt
.
cbData
)))
{
/* generate random salt */
if
(
!
CryptGenRandom
(
hProv
,
pInfo
->
salt
.
cbData
,
pInfo
->
salt
.
pbData
))
...
...
@@ -667,7 +667,7 @@ BOOL convert_hash_to_blob(HCRYPTHASH hHash, DATA_BLOB * blob)
return
FALSE
;
}
if
(
!
(
blob
->
pbData
=
HeapAlloc
(
GetProcessHeap
(),
0
,
blob
->
cbData
)))
if
(
!
(
blob
->
pbData
=
CryptMemAlloc
(
blob
->
cbData
)))
{
ERR
(
"failed to allocate blob memory
\n
"
);
return
FALSE
;
...
...
@@ -677,7 +677,7 @@ BOOL convert_hash_to_blob(HCRYPTHASH hHash, DATA_BLOB * blob)
if
(
!
CryptGetHashParam
(
hHash
,
HP_HASHVAL
,
blob
->
pbData
,
&
dwSize
,
0
))
{
ERR
(
"failed to get hash value
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
blob
->
pbData
);
CryptMemFree
(
blob
->
pbData
);
blob
->
pbData
=
NULL
;
blob
->
cbData
=
0
;
return
FALSE
;
...
...
@@ -705,7 +705,7 @@ BOOL hash_matches_blob(HCRYPTHASH hHash, DATA_BLOB * two)
rc
=
TRUE
;
}
HeapFree
(
GetProcessHeap
(),
0
,
one
.
pbData
);
CryptMemFree
(
one
.
pbData
);
return
rc
;
}
...
...
@@ -733,7 +733,7 @@ BOOL load_encryption_key(HCRYPTPROV hProv, DATA_BLOB * salt,
dwUsernameLen
=
0
;
if
(
!
GetUserNameA
(
NULL
,
&
dwUsernameLen
)
&&
GetLastError
()
==
ERROR_MORE_DATA
&&
dwUsernameLen
&&
(
szUsername
=
HeapAlloc
(
GetProcessHeap
(),
0
,
dwUsernameLen
)))
(
szUsername
=
CryptMemAlloc
(
dwUsernameLen
)))
{
szUsername
[
0
]
=
'\0'
;
GetUserNameA
(
szUsername
,
&
dwUsernameLen
);
...
...
@@ -768,7 +768,7 @@ BOOL load_encryption_key(HCRYPTPROV hProv, DATA_BLOB * salt,
/* clean up */
CryptDestroyHash
(
hSaltHash
);
if
(
szUsername
)
HeapFree
(
GetProcessHeap
(),
0
,
szUsername
);
if
(
szUsername
)
CryptMemFree
(
szUsername
);
return
rc
;
}
...
...
@@ -902,10 +902,10 @@ BOOL WINAPI CryptProtectData(DATA_BLOB* pDataIn,
/* copy plain text into cipher area for CryptEncrypt call */
protect_data
.
cipher
.
cbData
=
dwLength
;
if
(
!
(
protect_data
.
cipher
.
pbData
=
HeapAlloc
(
GetProcessHeap
(),
0
,
if
(
!
(
protect_data
.
cipher
.
pbData
=
CryptMemAlloc
(
protect_data
.
cipher
.
cbData
)))
{
ERR
(
"
Heap
Alloc
\n
"
);
ERR
(
"
CryptMem
Alloc
\n
"
);
goto
free_hash
;
}
memcpy
(
protect_data
.
cipher
.
pbData
,
pDataIn
->
pbData
,
pDataIn
->
cbData
);
...
...
@@ -1068,7 +1068,7 @@ BOOL WINAPI CryptUnprotectData(DATA_BLOB* pDataIn,
pDataOut
->
cbData
=
protect_data
.
cipher
.
cbData
;
if
(
!
(
pDataOut
->
pbData
=
LocalAlloc
(
LPTR
,
pDataOut
->
cbData
)))
{
ERR
(
"
Heap
Alloc
\n
"
);
ERR
(
"
CryptMem
Alloc
\n
"
);
goto
free_hash
;
}
memcpy
(
pDataOut
->
pbData
,
protect_data
.
cipher
.
pbData
,
protect_data
.
cipher
.
cbData
);
...
...
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