From 2b384cb0e9f0b0ffd1e55d1a5106a41ad19fbff2 Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Thu, 11 Dec 2008 15:21:47 -0800 Subject: [PATCH] crypt32: Validate input arguments to CryptQueryObject. --- dlls/crypt32/object.c | 13 +++++++++++++ dlls/crypt32/tests/object.c | 2 -- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/dlls/crypt32/object.c b/dlls/crypt32/object.c index 825dad587f..f6e0c844e0 100644 --- a/dlls/crypt32/object.c +++ b/dlls/crypt32/object.c @@ -492,6 +492,19 @@ BOOL WINAPI CryptQueryObject(DWORD dwObjectType, const void *pvObject, dwExpectedFormatTypeFlags, dwFlags, pdwMsgAndCertEncodingType, pdwContentType, pdwFormatType, phCertStore, phMsg, ppvContext); + if (dwObjectType != CERT_QUERY_OBJECT_BLOB && + dwObjectType != CERT_QUERY_OBJECT_FILE) + { + WARN("unsupported type %d\n", dwObjectType); + SetLastError(E_INVALIDARG); + return FALSE; + } + if (!pvObject) + { + WARN("missing required argument\n"); + SetLastError(E_INVALIDARG); + return FALSE; + } if (dwExpectedContentTypeFlags & unimplementedTypes) WARN("unimplemented for types %08x\n", dwExpectedContentTypeFlags & unimplementedTypes); diff --git a/dlls/crypt32/tests/object.c b/dlls/crypt32/tests/object.c index 6782cb00dc..23f3597958 100644 --- a/dlls/crypt32/tests/object.c +++ b/dlls/crypt32/tests/object.c @@ -130,13 +130,11 @@ static void test_query_object(void) SetLastError(0xdeadbeef); ret = CryptQueryObject(0, NULL, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL); - todo_wine ok(!ret && GetLastError() == E_INVALIDARG, "expected E_INVALIDARG, got %08x\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, NULL, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL); - todo_wine ok(!ret && GetLastError() == E_INVALIDARG, "expected E_INVALIDARG, got %08x\n", GetLastError()); /* Test with a simple cert */ -- 2.33.8