Commit 297f1122 authored by Daniel McArdle's avatar Daniel McArdle Committed by Commit Bot

Add null-checks to Android client cert logic

With this commit, StartClientCertificateRequest null-checks the
ViewAndroidHelper, ViewAndroid, and WindowAndroid pointers before
dereferencing them.

This is a speculative fix for the attached bug.

Bug: 1048855
Change-Id: Ibb677fe94238428fa6f31b375fc327336dcb1d8e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2039893
Commit-Queue: Dan McArdle <dmcardle@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738723}
parent 97ff4813
...@@ -139,6 +139,23 @@ class SSLClientCertPendingRequests ...@@ -139,6 +139,23 @@ class SSLClientCertPendingRequests
WEB_CONTENTS_USER_DATA_KEY_DECL(); WEB_CONTENTS_USER_DATA_KEY_DECL();
}; };
ui::WindowAndroid* GetWindowFromWebContents(
content::WebContents* web_contents) {
ViewAndroidHelper* view_helper =
ViewAndroidHelper::FromWebContents(web_contents);
if (view_helper == nullptr) {
LOG(ERROR) << "Could not get ViewAndroidHelper";
return nullptr;
}
ui::ViewAndroid* view = view_helper->GetViewAndroid();
if (view == nullptr) {
LOG(ERROR) << "Could not get ViewAndroid";
return nullptr;
}
// May return nullptr.
return view->GetWindowAndroid();
}
WEB_CONTENTS_USER_DATA_KEY_IMPL(SSLClientCertPendingRequests) WEB_CONTENTS_USER_DATA_KEY_IMPL(SSLClientCertPendingRequests)
static void StartClientCertificateRequest( static void StartClientCertificateRequest(
...@@ -146,10 +163,11 @@ static void StartClientCertificateRequest( ...@@ -146,10 +163,11 @@ static void StartClientCertificateRequest(
content::WebContents* web_contents) { content::WebContents* web_contents) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
ui::WindowAndroid* window = ViewAndroidHelper::FromWebContents(web_contents) ui::WindowAndroid* window = GetWindowFromWebContents(web_contents);
->GetViewAndroid() if (window == nullptr) {
->GetWindowAndroid(); LOG(ERROR) << "Could not get Window";
DCHECK(window); return;
}
// Build the |key_types| JNI parameter, as a String[] // Build the |key_types| JNI parameter, as a String[]
std::vector<std::string> key_types; std::vector<std::string> key_types;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment