OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/safe_browsing/signature_util.h" | 5 #include "chrome/browser/safe_browsing/signature_util.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <softpub.h> | 8 #include <softpub.h> |
9 #include <wintrust.h> | 9 #include <wintrust.h> |
10 | 10 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 CRYPT_PROVIDER_DATA* prov_data = WTHelperProvDataFromStateData( | 58 CRYPT_PROVIDER_DATA* prov_data = WTHelperProvDataFromStateData( |
59 wintrust_data.hWVTStateData); | 59 wintrust_data.hWVTStateData); |
60 if (prov_data) { | 60 if (prov_data) { |
61 if (prov_data->csSigners > 0) { | 61 if (prov_data->csSigners > 0) { |
62 signature_info->set_trusted(result == ERROR_SUCCESS); | 62 signature_info->set_trusted(result == ERROR_SUCCESS); |
63 } | 63 } |
64 for (DWORD i = 0; i < prov_data->csSigners; ++i) { | 64 for (DWORD i = 0; i < prov_data->csSigners; ++i) { |
65 const CERT_CHAIN_CONTEXT* cert_chain_context = | 65 const CERT_CHAIN_CONTEXT* cert_chain_context = |
66 prov_data->pasSigners[i].pChainContext; | 66 prov_data->pasSigners[i].pChainContext; |
| 67 if (!cert_chain_context) |
| 68 break; |
67 for (DWORD j = 0; j < cert_chain_context->cChain; ++j) { | 69 for (DWORD j = 0; j < cert_chain_context->cChain; ++j) { |
68 CERT_SIMPLE_CHAIN* simple_chain = cert_chain_context->rgpChain[j]; | 70 CERT_SIMPLE_CHAIN* simple_chain = cert_chain_context->rgpChain[j]; |
69 ClientDownloadRequest_CertificateChain* chain = | 71 ClientDownloadRequest_CertificateChain* chain = |
70 signature_info->add_certificate_chain(); | 72 signature_info->add_certificate_chain(); |
| 73 if (!simple_chain) |
| 74 break; |
71 for (DWORD k = 0; k < simple_chain->cElement; ++k) { | 75 for (DWORD k = 0; k < simple_chain->cElement; ++k) { |
72 CERT_CHAIN_ELEMENT* element = simple_chain->rgpElement[k]; | 76 CERT_CHAIN_ELEMENT* element = simple_chain->rgpElement[k]; |
73 chain->add_element()->set_certificate( | 77 chain->add_element()->set_certificate( |
74 element->pCertContext->pbCertEncoded, | 78 element->pCertContext->pbCertEncoded, |
75 element->pCertContext->cbCertEncoded); | 79 element->pCertContext->cbCertEncoded); |
76 } | 80 } |
77 } | 81 } |
78 } | 82 } |
79 | 83 |
80 // Free the provider data. | 84 // Free the provider data. |
81 wintrust_data.dwStateAction = WTD_STATEACTION_CLOSE; | 85 wintrust_data.dwStateAction = WTD_STATEACTION_CLOSE; |
82 WinVerifyTrust(static_cast<HWND>(INVALID_HANDLE_VALUE), | 86 WinVerifyTrust(static_cast<HWND>(INVALID_HANDLE_VALUE), |
83 &policy_guid, &wintrust_data); | 87 &policy_guid, &wintrust_data); |
84 } | 88 } |
85 } | 89 } |
86 | 90 |
87 } // namespace safe_browsing | 91 } // namespace safe_browsing |
OLD | NEW |