⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 244035 in webkit


Ignore:
Timestamp:
Apr 8, 2019, 1:24:34 PM (7 years ago)
Author:
Brent Fulgham
Message:

Make HSTS list handling more robust against unexpected content
https://bugs.webkit.org/show_bug.cgi?id=196552
<rdar://problem/43403817>

Reviewed by Chris Dumez.

Crash logs indicate we sometimes encounter null key values during processing.
This patch adds some debug assertions to catch this in test environments, and
allows the code to skip the bad entries if encountered.

It also avoids calling CFDictionaryApplyFunction when the HSTS policies returned
by _CFNetworkCopyHSTSPolicies is nullptr, which is a possible return value.

  • NetworkProcess/cocoa/NetworkProcessCocoa.mm:

(WebKit::filterPreloadHSTSEntry):
(WebKit::NetworkProcess::getHostNamesWithHSTSCache):

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r244033 r244035  
     12019-04-08  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Make HSTS list handling more robust against unexpected content
     4        https://bugs.webkit.org/show_bug.cgi?id=196552
     5        <rdar://problem/43403817>
     6
     7        Reviewed by Chris Dumez.
     8
     9        Crash logs indicate we sometimes encounter null key values during processing.
     10        This patch adds some debug assertions to catch this in test environments, and
     11        allows the code to skip the bad entries if encountered.
     12
     13        It also avoids calling CFDictionaryApplyFunction when the HSTS policies returned
     14        by _CFNetworkCopyHSTSPolicies is nullptr, which is a possible return value.
     15
     16        * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
     17        (WebKit::filterPreloadHSTSEntry):
     18        (WebKit::NetworkProcess::getHostNamesWithHSTSCache):
     19
    1202019-04-05  Brian Burg  <bburg@apple.com>
    221
  • trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm

    r243427 r244035  
    150150static void filterPreloadHSTSEntry(const void* key, const void* value, void* context)
    151151{
    152     HashSet<String>* hostnames = static_cast<HashSet<String>*>(context);
     152    RELEASE_ASSERT(context);
     153
     154    ASSERT(key);
     155    ASSERT(value);
     156    if (!key || !value)
     157        return;
     158
     159    ASSERT(key != kCFNull);
     160    if (key == kCFNull)
     161        return;
     162   
     163    auto* hostnames = static_cast<HashSet<String>*>(context);
    153164    auto val = static_cast<CFDictionaryRef>(value);
    154165    if (CFDictionaryGetValue(val, _kCFNetworkHSTSPreloaded) != kCFBooleanTrue)
     
    158169void NetworkProcess::getHostNamesWithHSTSCache(WebCore::NetworkStorageSession& session, HashSet<String>& hostNames)
    159170{
    160     auto HSTSPolicies = adoptCF(_CFNetworkCopyHSTSPolicies(session.platformSession()));
    161     CFDictionaryApplyFunction(HSTSPolicies.get(), filterPreloadHSTSEntry, &hostNames);
     171    if (auto HSTSPolicies = adoptCF(_CFNetworkCopyHSTSPolicies(session.platformSession())))
     172        CFDictionaryApplyFunction(HSTSPolicies.get(), filterPreloadHSTSEntry, &hostNames);
    162173}
    163174
Note: See TracChangeset for help on using the changeset viewer.