[PATCH] crypt32: NULL ptr could leak into function (Coverity)

Marcus Meissner marcus at jet.franken.de
Fri Dec 31 05:00:22 CST 2010


Hi,

(flushing old patches again from my tree)

CID 596, a NULL pvEncoded could leak further into the
function and would then lead to crash. So just return
error if we see one.

Ciao, Marcus
---
 dlls/crypt32/encode.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/dlls/crypt32/encode.c b/dlls/crypt32/encode.c
index 5d6affe..f10c92e 100644
--- a/dlls/crypt32/encode.c
+++ b/dlls/crypt32/encode.c
@@ -4628,8 +4628,13 @@ BOOL WINAPI CryptEncodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType,
     }
 
     SetLastError(NOERROR);
-    if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG && pvEncoded)
+    if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG) {
+        if (!pvEncoded) {
+            SetLastError(ERROR_INVALID_PARAMETER);
+            return FALSE;
+        }
         *(BYTE **)pvEncoded = NULL;
+    }
     encodeFunc = CRYPT_GetBuiltinEncoder(dwCertEncodingType, lpszStructType);
     if (!encodeFunc)
     {
-- 
1.7.1



More information about the wine-patches mailing list