| 
									
										
										
										
											2022-10-12 11:27:25 +11:00
										 |  |  | From 452d18312589f22e6dcfcba61b4901ae30537540 Mon Sep 17 00:00:00 2001 | 
					
						
							| 
									
										
										
										
											2018-04-26 11:24:46 +10:00
										 |  |  | From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com> | 
					
						
							|  |  |  | Date: Wed, 18 Apr 2018 03:55:16 +0000 | 
					
						
							|  |  |  | Subject: [PATCH] wintrust: Add parameter check in WTHelperGetProvCertFromChain | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com> | 
					
						
							|  |  |  | ---
 | 
					
						
							|  |  |  |  dlls/wintrust/tests/softpub.c | 9 +++++++++ | 
					
						
							|  |  |  |  dlls/wintrust/wintrust_main.c | 2 +- | 
					
						
							| 
									
										
										
										
											2022-10-12 11:27:25 +11:00
										 |  |  |  3 files changed, 11 insertions(+), 2 deletions(-) | 
					
						
							| 
									
										
										
										
											2018-04-26 11:24:46 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | diff --git a/dlls/wintrust/tests/softpub.c b/dlls/wintrust/tests/softpub.c
 | 
					
						
							| 
									
										
										
										
											2022-10-12 11:27:25 +11:00
										 |  |  | index 77e15b2feb4..219fd8dc26f 100644
 | 
					
						
							| 
									
										
										
										
											2018-04-26 11:24:46 +10:00
										 |  |  | --- a/dlls/wintrust/tests/softpub.c
 | 
					
						
							|  |  |  | +++ b/dlls/wintrust/tests/softpub.c
 | 
					
						
							| 
									
										
										
										
											2022-10-12 11:27:25 +11:00
										 |  |  | @@ -1892,6 +1892,14 @@ static void test_multiple_signatures(void)
 | 
					
						
							|  |  |  |      DeleteFileW(pathW); | 
					
						
							| 
									
										
										
										
											2018-04-26 11:24:46 +10:00
										 |  |  |  } | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  | +static void test_WTHelperGetProvCertFromChain(void)
 | 
					
						
							|  |  |  | +{
 | 
					
						
							|  |  |  | +    CRYPT_PROVIDER_CERT *cert;
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  | +    cert = WTHelperGetProvCertFromChain(NULL, 0);
 | 
					
						
							|  |  |  | +    ok(!cert, "got certificate\n");
 | 
					
						
							|  |  |  | +}
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  |  START_TEST(softpub) | 
					
						
							|  |  |  |  { | 
					
						
							|  |  |  |      InitFunctionPtrs(); | 
					
						
							| 
									
										
										
										
											2022-10-12 11:27:25 +11:00
										 |  |  | @@ -1900,5 +1908,6 @@ START_TEST(softpub)
 | 
					
						
							| 
									
										
										
										
											2018-04-26 11:24:46 +10:00
										 |  |  |      test_wintrust(); | 
					
						
							|  |  |  |      test_wintrust_digest(); | 
					
						
							|  |  |  |      test_get_known_usages(); | 
					
						
							|  |  |  | +    test_WTHelperGetProvCertFromChain();
 | 
					
						
							| 
									
										
										
										
											2022-10-12 11:27:25 +11:00
										 |  |  |      test_multiple_signatures(); | 
					
						
							| 
									
										
										
										
											2018-04-26 11:24:46 +10:00
										 |  |  |  } | 
					
						
							|  |  |  | diff --git a/dlls/wintrust/wintrust_main.c b/dlls/wintrust/wintrust_main.c
 | 
					
						
							| 
									
										
										
										
											2022-10-12 11:27:25 +11:00
										 |  |  | index 925ae7ca85a..c48dbbfe2d8 100644
 | 
					
						
							| 
									
										
										
										
											2018-04-26 11:24:46 +10:00
										 |  |  | --- a/dlls/wintrust/wintrust_main.c
 | 
					
						
							|  |  |  | +++ b/dlls/wintrust/wintrust_main.c
 | 
					
						
							| 
									
										
										
										
											2022-10-12 11:27:25 +11:00
										 |  |  | @@ -786,7 +786,7 @@ CRYPT_PROVIDER_CERT * WINAPI WTHelperGetProvCertFromChain(
 | 
					
						
							| 
									
										
										
										
											2018-04-26 11:24:46 +10:00
										 |  |  |   | 
					
						
							| 
									
										
										
										
											2022-02-23 14:27:11 +11:00
										 |  |  |      TRACE("(%p %ld)\n", pSgnr, idxCert); | 
					
						
							| 
									
										
										
										
											2018-04-26 11:24:46 +10:00
										 |  |  |   | 
					
						
							|  |  |  | -    if (idxCert >= pSgnr->csCertChain || !pSgnr->pasCertChain)
 | 
					
						
							|  |  |  | +    if (!pSgnr || idxCert >= pSgnr->csCertChain || !pSgnr->pasCertChain)
 | 
					
						
							|  |  |  |          return NULL; | 
					
						
							|  |  |  |      cert = &pSgnr->pasCertChain[idxCert]; | 
					
						
							|  |  |  |      TRACE("returning %p\n", cert); | 
					
						
							|  |  |  | -- 
 | 
					
						
							| 
									
										
										
										
											2022-10-12 11:27:25 +11:00
										 |  |  | 2.37.2 | 
					
						
							| 
									
										
										
										
											2018-04-26 11:24:46 +10:00
										 |  |  | 
 |