[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.

Adjusted after Juans comments.

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

diff --git a/dlls/crypt32/decode.c b/dlls/crypt32/decode.c
index 1fd2383..1fda2a0 100644
--- a/dlls/crypt32/decode.c
+++ b/dlls/crypt32/decode.c
@@ -5885,8 +5885,9 @@ BOOL WINAPI CryptDecodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType,
             {
                 ret = pCryptDecodeObject(dwCertEncodingType, lpszStructType,
                  pbEncoded, cbEncoded, dwFlags, NULL, pcbStructInfo);
-                if (ret && (ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara,
-                 pvStructInfo, pcbStructInfo, *pcbStructInfo)))
+                if (ret && pvStructInfo &&
+                 (ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara,
+                  pvStructInfo, pcbStructInfo, *pcbStructInfo)))
                     ret = pCryptDecodeObject(dwCertEncodingType,
                      lpszStructType, pbEncoded, cbEncoded, dwFlags,
                      *(BYTE **)pvStructInfo, pcbStructInfo);
diff --git a/dlls/crypt32/encode.c b/dlls/crypt32/encode.c
index b7bbc83..585c696 100644
--- a/dlls/crypt32/encode.c
+++ b/dlls/crypt32/encode.c
@@ -4597,8 +4597,8 @@ BOOL WINAPI CryptEncodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType,
             {
                 ret = pCryptEncodeObject(dwCertEncodingType, lpszStructType,
                  pvStructInfo, NULL, pcbEncoded);
-                if (ret && (ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
-                 pvEncoded, pcbEncoded, *pcbEncoded)))
+                if (ret && pvStructInfo && (ret = CRYPT_EncodeEnsureSpace(
+                 dwFlags, pEncodePara, pvEncoded, pcbEncoded, *pcbEncoded)))
                     ret = pCryptEncodeObject(dwCertEncodingType,
                      lpszStructType, pvStructInfo, *(BYTE **)pvEncoded,
                      pcbEncoded);
-- 
1.5.6




More information about the wine-devel mailing list