Changeset 182602 in webkit


Ignore:
Timestamp:
Apr 9, 2015 9:20:21 AM (9 years ago)
Author:
Antti Koivisto
Message:

Network Cache: Crash in WebCore::CachedResource::tryReplaceEncodedData
https://bugs.webkit.org/show_bug.cgi?id=143562

Reviewed by Anders Carlsson.

If another thread comes and truncates the file before we map it we end up with a map that crashes when accessed.

  • NetworkProcess/cache/NetworkCacheIOChannelCocoa.mm:

(WebKit::NetworkCache::IOChannel::IOChannel):

When creating a new file unlink any existing file instead of using O_TRUNC.

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r182598 r182602  
     12015-04-09  Antti Koivisto  <antti@apple.com>
     2
     3        Network Cache: Crash in WebCore::CachedResource::tryReplaceEncodedData
     4        https://bugs.webkit.org/show_bug.cgi?id=143562
     5
     6        Reviewed by Anders Carlsson.
     7
     8        If another thread comes and truncates the file before we map it we end up with a map that crashes when accessed.
     9
     10        * NetworkProcess/cache/NetworkCacheIOChannelCocoa.mm:
     11        (WebKit::NetworkCache::IOChannel::IOChannel):
     12
     13            When creating a new file unlink any existing file instead of using O_TRUNC.
     14
    1152015-04-09  Csaba Osztrogonác  <ossy@webkit.org>
    216
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheIOChannelCocoa.mm

    r181700 r182602  
    4444    , m_type(type)
    4545{
     46    auto path = WebCore::fileSystemRepresentation(filePath);
    4647    int oflag;
    4748    mode_t mode;
     
    4950    switch (m_type) {
    5051    case Type::Create:
    51         oflag = O_RDWR | O_CREAT | O_TRUNC | O_NONBLOCK;
     52        // We don't want to truncate any existing file (with O_TRUNC) as another thread might be mapping it.
     53        unlink(path.data());
     54        oflag = O_RDWR | O_CREAT | O_NONBLOCK;
    5255        mode = S_IRUSR | S_IWUSR;
    5356        break;
     
    6164    }
    6265
    63     CString path = WebCore::fileSystemRepresentation(filePath);
    6466    int fd = ::open(path.data(), oflag, mode);
    6567    m_fileDescriptor = fd;
Note: See TracChangeset for help on using the changeset viewer.