Changeset 228696 in webkit


Ignore:
Timestamp:
Feb 19, 2018 10:34:07 AM (6 years ago)
Author:
dbates@webkit.org
Message:

Null pointer dereference in WebPageProxy::urlSchemeHandlerForScheme()
https://bugs.webkit.org/show_bug.cgi?id=182905

Reviewed by Alex Christensen.

Return nullptr when querying for the scheme handler of the null string.

Before a navigation is performed WebKit checks if the destination URL is associated with an app
unless the embedding client overrides the WKNavigationDelegate delegate callback -webView:decidePolicyForNavigationAction:decisionHandler.
If the URL is not associated with an app then WebKit may fall back to checking if the embedding
client registered a scheme handler for it. Currently we assume that the scheme is a non-null
string when checking the scheme handler registry. However the scheme can be a null string if
it is part of a malformed URL. And this leads to bad news bears when we try to use it to look
for a scheme handler. Instead check that the scheme is a non-null string before checking to see
if it is in the scheme handler registry.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::urlSchemeHandlerForScheme):

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r228691 r228696  
     12018-02-19  Daniel Bates  <dabates@apple.com>
     2
     3        Null pointer dereference in WebPageProxy::urlSchemeHandlerForScheme()
     4        https://bugs.webkit.org/show_bug.cgi?id=182905
     5
     6        Reviewed by Alex Christensen.
     7
     8        Return nullptr when querying for the scheme handler of the null string.
     9
     10        Before a navigation is performed WebKit checks if the destination URL is associated with an app
     11        unless the embedding client overrides the WKNavigationDelegate delegate callback -webView:decidePolicyForNavigationAction:decisionHandler.
     12        If the URL is not associated with an app then WebKit may fall back to checking if the embedding
     13        client registered a scheme handler for it. Currently we assume that the scheme is a non-null
     14        string when checking the scheme handler registry. However the scheme can be a null string if
     15        it is part of a malformed URL. And this leads to bad news bears when we try to use it to look
     16        for a scheme handler. Instead check that the scheme is a non-null string before checking to see
     17        if it is in the scheme handler registry.
     18
     19        * UIProcess/WebPageProxy.cpp:
     20        (WebKit::WebPageProxy::urlSchemeHandlerForScheme):
     21
    1222018-02-19  Ms2ger  <Ms2ger@igalia.com>
    223
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r228587 r228696  
    72007200WebURLSchemeHandler* WebPageProxy::urlSchemeHandlerForScheme(const String& scheme)
    72017201{
    7202     return m_urlSchemeHandlersByScheme.get(scheme);
     7202    return scheme.isNull() ? nullptr : m_urlSchemeHandlersByScheme.get(scheme);
    72037203}
    72047204
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/DecidePolicyForNavigationAction.mm

    r225645 r228696  
    562562}
    563563
     564@interface DecidePolicyForNavigationActionForMalformedURLDelegate : NSObject <WKNavigationDelegate>
     565@end
     566
     567@implementation DecidePolicyForNavigationActionForMalformedURLDelegate
     568
     569- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
     570{
     571    finishedNavigation = true;
     572}
     573
     574@end
     575
     576TEST(WebKit, DecidePolicyForNavigationActionForMalformedURL)
     577{
     578    auto webView = adoptNS([[WKWebView alloc] init]);
     579    auto controller = adoptNS([[DecidePolicyForNavigationActionForMalformedURLDelegate alloc] init]);
     580    [webView setNavigationDelegate:controller.get()];
     581
     582    finishedNavigation = false;
     583    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"N"]]];
     584    TestWebKitAPI::Util::run(&finishedNavigation);
     585}
     586
    564587#endif
    565588
Note: See TracChangeset for help on using the changeset viewer.