From 452d18312589f22e6dcfcba61b4901ae30537540 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 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/dlls/wintrust/tests/softpub.c b/dlls/wintrust/tests/softpub.c index 77e15b2feb4..219fd8dc26f 100644 --- a/dlls/wintrust/tests/softpub.c +++ b/dlls/wintrust/tests/softpub.c @@ -1892,6 +1892,14 @@ static void test_multiple_signatures(void) DeleteFileW(pathW); } +static void test_WTHelperGetProvCertFromChain(void) +{ + CRYPT_PROVIDER_CERT *cert; + + cert = WTHelperGetProvCertFromChain(NULL, 0); + ok(!cert, "got certificate\n"); +} + START_TEST(softpub) { InitFunctionPtrs(); @@ -1900,5 +1908,6 @@ START_TEST(softpub) test_wintrust(); test_wintrust_digest(); test_get_known_usages(); + test_WTHelperGetProvCertFromChain(); test_multiple_signatures(); } diff --git a/dlls/wintrust/wintrust_main.c b/dlls/wintrust/wintrust_main.c index 925ae7ca85a..c48dbbfe2d8 100644 --- a/dlls/wintrust/wintrust_main.c +++ b/dlls/wintrust/wintrust_main.c @@ -786,7 +786,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.37.2