[PATCH] crypt32: check for NULL target pointers (Coverity)

Marcus Meissner marcus at jet.franken.de
Tue Dec 22 03:20:25 CST 2009


Hi,

CID 596 and 595 ... we happily dereference pvEncoded
as NULL (if pcbEncoded is non-NULL), and pvStructInfo
(if pcbStructInfo is non-NULL).

Windows shows varying behaviour apparently, either
crash or error return... So we can chose error return too.

(Or wrap the whole function in a __TRY __EXPECT? )

Ciao, Marcus
---
 dlls/crypt32/decode.c |    4 ++++
 dlls/crypt32/encode.c |    4 ++++
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/dlls/crypt32/decode.c b/dlls/crypt32/decode.c
index 1fd2383..67f983f 100644
--- a/dlls/crypt32/decode.c
+++ b/dlls/crypt32/decode.c
@@ -212,6 +212,10 @@ static BOOL CRYPT_DecodeEnsureSpace(DWORD dwFlags,
 
     if (dwFlags & CRYPT_DECODE_ALLOC_FLAG)
     {
+        if (!pvStructInfo) {
+            SetLastError(ERROR_INVALID_PARAMETER);
+            return FALSE;
+        }
         if (pDecodePara && pDecodePara->pfnAlloc)
             *(BYTE **)pvStructInfo = pDecodePara->pfnAlloc(bytesNeeded);
         else
diff --git a/dlls/crypt32/encode.c b/dlls/crypt32/encode.c
index b7bbc83..6bb6d76 100644
--- a/dlls/crypt32/encode.c
+++ b/dlls/crypt32/encode.c
@@ -107,6 +107,10 @@ BOOL CRYPT_EncodeEnsureSpace(DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara,
 
     if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG)
     {
+        if (!pbEncoded) {
+            SetLastError(ERROR_INVALID_PARAMETER);
+            return FALSE;
+        }
         if (pEncodePara && pEncodePara->pfnAlloc)
             *(BYTE **)pbEncoded = pEncodePara->pfnAlloc(bytesNeeded);
         else
-- 
1.5.6



More information about the wine-patches mailing list