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.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182602
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2015-04-09 Antti Koivisto <antti@apple.com>
+
+ 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.
+
2015-04-09 Csaba Osztrogonác <ossy@webkit.org>
[EFL][GTK] WebKit2's generate-forwarding-headers.pl runs too many times
: m_path(filePath)
, m_type(type)
{
+ auto path = WebCore::fileSystemRepresentation(filePath);
int oflag;
mode_t mode;
switch (m_type) {
case Type::Create:
- oflag = O_RDWR | O_CREAT | O_TRUNC | O_NONBLOCK;
+ // We don't want to truncate any existing file (with O_TRUNC) as another thread might be mapping it.
+ unlink(path.data());
+ oflag = O_RDWR | O_CREAT | O_NONBLOCK;
mode = S_IRUSR | S_IWUSR;
break;
case Type::Write:
mode = 0;
}
- CString path = WebCore::fileSystemRepresentation(filePath);
int fd = ::open(path.data(), oflag, mode);
m_fileDescriptor = fd;