diff --git a/dlls/crypt32/object.c b/dlls/crypt32/object.c index f6e0c844e06..0674c795e2a 100644 --- a/dlls/crypt32/object.c +++ b/dlls/crypt32/object.c @@ -163,6 +163,7 @@ static BOOL CRYPT_QuerySerializedContextObject(DWORD dwObjectType, if (!ret) return FALSE; + ret = FALSE; context = CRYPT_ReadSerializedElement(blob->pbData, blob->cbData, CERT_STORE_ALL_CONTEXT_FLAG, &contextType); if (context) @@ -563,6 +564,8 @@ BOOL WINAPI CryptQueryObject(DWORD dwObjectType, const void *pvObject, dwExpectedContentTypeFlags, pdwMsgAndCertEncodingType, pdwContentType, phCertStore, phMsg); } + if (!ret) + SetLastError(CRYPT_E_NO_MATCH); TRACE("returning %d\n", ret); return ret; } diff --git a/dlls/crypt32/tests/object.c b/dlls/crypt32/tests/object.c index 23f35979583..6e440c65ddf 100644 --- a/dlls/crypt32/tests/object.c +++ b/dlls/crypt32/tests/object.c @@ -152,13 +152,13 @@ static void test_query_object(void) ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + todo_wine ok(ret, "CryptQueryObject failed: %08x\n", GetLastError()); /* The same base64-encoded cert, restricting the format types */ SetLastError(0xdeadbeef); ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_BINARY, 0, NULL, NULL, NULL, NULL, NULL, NULL); - todo_wine ok(!ret && GetLastError() == CRYPT_E_NO_MATCH, "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError()); SetLastError(0xdeadbeef); @@ -174,7 +174,6 @@ static void test_query_object(void) ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL, NULL, NULL, NULL, NULL); - todo_wine ok(!ret && GetLastError() == CRYPT_E_NO_MATCH, "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError()); /* For brevity, not tested here, but tested on Windows: same failure @@ -195,6 +194,7 @@ static void test_query_object(void) ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + todo_wine ok(ret, "CryptQueryObject failed: %08x\n", GetLastError()); /* A valid signed message, encoded as a wide character base64 string, can * be queried successfully. @@ -205,12 +205,12 @@ static void test_query_object(void) ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + todo_wine ok(ret, "CryptQueryObject failed: %08x\n", GetLastError()); SetLastError(0xdeadbeef); ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_BINARY, 0, NULL, NULL, NULL, NULL, NULL, NULL); - todo_wine ok(!ret && GetLastError() == CRYPT_E_NO_MATCH, "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError()); SetLastError(0xdeadbeef);