From 23c86326fda0da27cd7c876ba6a63ab05f23c299 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Wed, 18 Apr 2018 03:55:16 +0000 Subject: [PATCH] wintrust: Add parameter check in WTHelperGetProvCertFromChain Signed-off-by: Alistair Leslie-Hughes --- dlls/wintrust/tests/softpub.c | 9 +++++++++ dlls/wintrust/wintrust_main.c | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/dlls/wintrust/tests/softpub.c b/dlls/wintrust/tests/softpub.c index 9654c296a78..44c92f91f08 100644 --- a/dlls/wintrust/tests/softpub.c +++ b/dlls/wintrust/tests/softpub.c @@ -1925,6 +1925,14 @@ static void test_pe_image_hash(void) DeleteFileW(path); } +static void test_WTHelperGetProvCertFromChain(void) +{ + CRYPT_PROVIDER_CERT *cert; + + cert = WTHelperGetProvCertFromChain(NULL, 0); + ok(!cert, "got certificate\n"); +} + START_TEST(softpub) { InitFunctionPtrs(); @@ -1933,6 +1941,7 @@ START_TEST(softpub) test_wintrust(); test_wintrust_digest(); test_get_known_usages(); + test_WTHelperGetProvCertFromChain(); test_multiple_signatures(); test_pe_image_hash(); } diff --git a/dlls/wintrust/wintrust_main.c b/dlls/wintrust/wintrust_main.c index a5c5706388a..8847115946a 100644 --- a/dlls/wintrust/wintrust_main.c +++ b/dlls/wintrust/wintrust_main.c @@ -765,7 +765,7 @@ CRYPT_PROVIDER_CERT * WINAPI WTHelperGetProvCertFromChain( TRACE("(%p %ld)\n", pSgnr, idxCert); - if (idxCert >= pSgnr->csCertChain || !pSgnr->pasCertChain) + if (!pSgnr || idxCert >= pSgnr->csCertChain || !pSgnr->pasCertChain) return NULL; cert = &pSgnr->pasCertChain[idxCert]; TRACE("returning %p\n", cert); -- 2.43.0