Changeset 202985 in webkit


Ignore:
Timestamp:
Jul 8, 2016, 10:11:20 AM (9 years ago)
Author:
Antti Koivisto
Message:

Regression(r201805): Crash with <use> resource that has Vary header
https://bugs.webkit.org/show_bug.cgi?id=159560
<rdar://problem/27034208>

Reviewed by Chris Dumez.

Source/WebCore:

In some situations (SVG <use> element for example) we may try to load resources from frameless documents.
Such loads always fail. The new vary header verification code path tried to access the frame earlier without
null check.

Test: http/tests/cache/vary-frameless-document.html

  • loader/cache/CachedResource.cpp:

(WebCore::CachedResource::failBeforeStarting):
(WebCore::addAdditionalRequestHeadersToRequest):

Null check frame.
Also move the resource type check here so all callers get the same behavior.

(WebCore::CachedResource::addAdditionalRequestHeaders):
(WebCore::CachedResource::load):
(WebCore::CachedResource::varyHeaderValuesMatch):

LayoutTests:

  • http/tests/cache/resources/svg-defs-vary.php: Added.
  • http/tests/cache/vary-frameless-document-expected.txt: Added.
  • http/tests/cache/vary-frameless-document.html: Added.
Location:
trunk
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r202983 r202985  
     12016-07-08  Antti Koivisto  <antti@apple.com>
     2
     3        Regression(r201805): Crash with <use> resource that has Vary header
     4        https://bugs.webkit.org/show_bug.cgi?id=159560
     5        <rdar://problem/27034208>
     6
     7        Reviewed by Chris Dumez.
     8
     9        * http/tests/cache/resources/svg-defs-vary.php: Added.
     10        * http/tests/cache/vary-frameless-document-expected.txt: Added.
     11        * http/tests/cache/vary-frameless-document.html: Added.
     12
    1132016-07-08  Commit Queue  <commit-queue@webkit.org>
    214
  • trunk/Source/WebCore/ChangeLog

    r202984 r202985  
     12016-07-08  Antti Koivisto  <antti@apple.com>
     2
     3        Regression(r201805): Crash with <use> resource that has Vary header
     4        https://bugs.webkit.org/show_bug.cgi?id=159560
     5        <rdar://problem/27034208>
     6
     7        Reviewed by Chris Dumez.
     8
     9        In some situations (SVG <use> element for example) we may try to load resources from frameless documents.
     10        Such loads always fail. The new vary header verification code path tried to access the frame earlier without
     11        null check.
     12
     13        Test: http/tests/cache/vary-frameless-document.html
     14
     15        * loader/cache/CachedResource.cpp:
     16        (WebCore::CachedResource::failBeforeStarting):
     17        (WebCore::addAdditionalRequestHeadersToRequest):
     18
     19            Null check frame.
     20            Also move the resource type check here so all callers get the same behavior.
     21
     22        (WebCore::CachedResource::addAdditionalRequestHeaders):
     23        (WebCore::CachedResource::load):
     24        (WebCore::CachedResource::varyHeaderValuesMatch):
     25
    1262016-07-08  Brady Eidson  <beidson@apple.com>
    227
  • trunk/Source/WebCore/loader/cache/CachedResource.cpp

    r202674 r202985  
    184184}
    185185
    186 static void addAdditionalRequestHeadersToRequest(ResourceRequest& request, const CachedResourceLoader& cachedResourceLoader)
    187 {
     186static void addAdditionalRequestHeadersToRequest(ResourceRequest& request, const CachedResourceLoader& cachedResourceLoader, CachedResource::Type type)
     187{
     188    if (type == CachedResource::MainResource)
     189        return;
     190    // In some cases we may try to load resources in frameless documents. Such loads always fail.
     191    // FIXME: We shouldn't get this far.
     192    if (!cachedResourceLoader.frame())
     193        return;
     194
    188195    // Note: We skip the Content-Security-Policy check here because we check
    189196    // the Content-Security-Policy at the CachedResourceLoader layer so we can
    190197    // handle different resource types differently.
    191 
    192198    FrameLoader& frameLoader = cachedResourceLoader.frame()->loader();
    193199    String outgoingReferrer;
     
    214220void CachedResource::addAdditionalRequestHeaders(CachedResourceLoader& cachedResourceLoader)
    215221{
    216     addAdditionalRequestHeadersToRequest(m_resourceRequest, cachedResourceLoader);
     222    addAdditionalRequestHeadersToRequest(m_resourceRequest, cachedResourceLoader, type());
    217223}
    218224
     
    276282    m_resourceRequest.setPriority(loadPriority());
    277283
    278     if (type() != MainResource)
    279         addAdditionalRequestHeaders(cachedResourceLoader);
     284    addAdditionalRequestHeaders(cachedResourceLoader);
    280285
    281286    // FIXME: It's unfortunate that the cache layer and below get to know anything about fragment identifiers.
     
    781786
    782787    ResourceRequest requestWithFullHeaders(request);
    783     addAdditionalRequestHeadersToRequest(requestWithFullHeaders, cachedResourceLoader);
     788    addAdditionalRequestHeadersToRequest(requestWithFullHeaders, cachedResourceLoader, type());
    784789
    785790    return verifyVaryingRequestHeaders(m_varyingHeaderValues, requestWithFullHeaders, m_sessionID);
Note: See TracChangeset for help on using the changeset viewer.