[PATCH] crypt32: change salt allocation to handle errors (Coverity 133)
Marcus Meissner
marcus at jet.franken.de
Sat Apr 4 11:34:56 CDT 2009
Hi,
Coverity 133 shows that we need a error handling on failing
memory allocation here.
Ciao, Marcus
---
dlls/crypt32/protectdata.c | 19 ++++++++++---------
1 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/dlls/crypt32/protectdata.c b/dlls/crypt32/protectdata.c
index 401e820..543c033 100644
--- a/dlls/crypt32/protectdata.c
+++ b/dlls/crypt32/protectdata.c
@@ -606,17 +606,18 @@ BOOL fill_protect_data(struct protect_data_t * pInfo, LPCWSTR szDataDescr,
pInfo->hash_len=CRYPT32_PROTECTDATA_HASH_LEN;
/* allocate memory to hold a salt */
- if ((pInfo->salt.pbData=CryptMemAlloc(CRYPT32_PROTECTDATA_SALT_LEN)))
+ if (NULL == (pInfo->salt.pbData=CryptMemAlloc(CRYPT32_PROTECTDATA_SALT_LEN))) {
+ ERR("could not allocate salt data blob\n");
+ return FALSE;
+ }
+ /* generate random salt */
+ if (!CryptGenRandom(hProv, pInfo->salt.cbData, pInfo->salt.pbData))
{
- /* generate random salt */
- if (!CryptGenRandom(hProv, pInfo->salt.cbData, pInfo->salt.pbData))
- {
- ERR("CryptGenRandom\n");
- free_protect_data(pInfo);
- return FALSE;
- }
- pInfo->salt.cbData=CRYPT32_PROTECTDATA_SALT_LEN;
+ ERR("CryptGenRandom\n");
+ free_protect_data(pInfo);
+ return FALSE;
}
+ pInfo->salt.cbData=CRYPT32_PROTECTDATA_SALT_LEN;
/* debug: show our salt */
TRACE_DATA_BLOB(&pInfo->salt);
--
1.5.6
More information about the wine-patches
mailing list