<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[210531] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/210531">210531</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2017-01-09 16:32:24 -0800 (Mon, 09 Jan 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>File scheme should not allow access of a resource on a different volume.
https://bugs.webkit.org/show_bug.cgi?id=158552
&lt;rdar://problem/15307582&gt;

Reviewed by Alex Christensen.

Source/WebCore:

Revise SecurityOrigin to prevent files from one storage device (volume) from accessing content
on a different storage device (volume) unless universal access is enabled.

Pass the current file device as part of the NSURLRequest so that CFNetwork can reject loads
where the device changes in the midst of a load.

Also properly reflect that SecurityOrigin is never null by passing as a reference,
rather than as a pointer.

Tests: Tools/TestWebKitAPI/Tests/mac/CrossPartitionFileSchemeAccess.mm

* page/SecurityOrigin.cpp:
(WebCore::SecurityOrigin::canAccess): Pass argument as reference.
(WebCore::SecurityOrigin::passesFileCheck): Add check that file URLs refer to files in
the same storage volume.
(WebCore::SecurityOrigin::canDisplay): Add check that files share the same volume.
(WebCore::SecurityOrigin::isSameSchemeHostPort): Pass argument as reference.
* page/SecurityOrigin.h:
* platform/FileSystem.cpp:
(WebCore::filesHaveSameVolume): Added.
* platform/FileSystem.h:
* platform/network/cocoa/ResourceRequestCocoa.mm:
(WebCore::ResourceRequest::doUpdatePlatformRequest): If loading a file URL, tell CFNetwork
the storage device at the time of the start of the load so we can trigger a failure if this
changes during the load operation.
* platform/posix/FileSystemPOSIX.cpp:
(WebCore::getFileDeviceId): Added.
* platform/win/FileSystemWin.cpp:
(WebCore::getFileDeviceId): Added.

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Add new files.
* TestWebKitAPI/Tests/mac/CrossPartitionFileSchemeAccess.html: Added.
* TestWebKitAPI/Tests/mac/CrossPartitionFileSchemeAccess.mm: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorepageSecurityOrigincpp">trunk/Source/WebCore/page/SecurityOrigin.cpp</a></li>
<li><a href="#trunkSourceWebCorepageSecurityOriginh">trunk/Source/WebCore/page/SecurityOrigin.h</a></li>
<li><a href="#trunkSourceWebCoreplatformFileSystemcpp">trunk/Source/WebCore/platform/FileSystem.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformFileSystemh">trunk/Source/WebCore/platform/FileSystem.h</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkcocoaResourceRequestCocoamm">trunk/Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformposixFileSystemPOSIXcpp">trunk/Source/WebCore/platform/posix/FileSystemPOSIX.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformwinFileSystemWincpp">trunk/Source/WebCore/platform/win/FileSystemWin.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsmacCrossPartitionFileSchemeAccesshtml">trunk/Tools/TestWebKitAPI/Tests/mac/CrossPartitionFileSchemeAccess.html</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsmacCrossPartitionFileSchemeAccessmm">trunk/Tools/TestWebKitAPI/Tests/mac/CrossPartitionFileSchemeAccess.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (210530 => 210531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-01-10 00:15:11 UTC (rev 210530)
+++ trunk/Source/WebCore/ChangeLog        2017-01-10 00:32:24 UTC (rev 210531)
</span><span class="lines">@@ -1,3 +1,41 @@
</span><ins>+2017-01-09  Brent Fulgham  &lt;bfulgham@apple.com&gt;
+
+        File scheme should not allow access of a resource on a different volume.
+        https://bugs.webkit.org/show_bug.cgi?id=158552
+        &lt;rdar://problem/15307582&gt;
+
+        Reviewed by Alex Christensen.
+
+        Revise SecurityOrigin to prevent files from one storage device (volume) from accessing content
+        on a different storage device (volume) unless universal access is enabled.
+
+        Pass the current file device as part of the NSURLRequest so that CFNetwork can reject loads
+        where the device changes in the midst of a load.
+
+        Also properly reflect that SecurityOrigin is never null by passing as a reference,
+        rather than as a pointer.
+
+        Tests: Tools/TestWebKitAPI/Tests/mac/CrossPartitionFileSchemeAccess.mm
+
+        * page/SecurityOrigin.cpp:
+        (WebCore::SecurityOrigin::canAccess): Pass argument as reference.
+        (WebCore::SecurityOrigin::passesFileCheck): Add check that file URLs refer to files in
+        the same storage volume.
+        (WebCore::SecurityOrigin::canDisplay): Add check that files share the same volume.
+        (WebCore::SecurityOrigin::isSameSchemeHostPort): Pass argument as reference.
+        * page/SecurityOrigin.h:
+        * platform/FileSystem.cpp:
+        (WebCore::filesHaveSameVolume): Added.
+        * platform/FileSystem.h:
+        * platform/network/cocoa/ResourceRequestCocoa.mm:
+        (WebCore::ResourceRequest::doUpdatePlatformRequest): If loading a file URL, tell CFNetwork
+        the storage device at the time of the start of the load so we can trigger a failure if this
+        changes during the load operation.
+        * platform/posix/FileSystemPOSIX.cpp:
+        (WebCore::getFileDeviceId): Added.
+        * platform/win/FileSystemWin.cpp:
+        (WebCore::getFileDeviceId): Added.
+
</ins><span class="cx"> 2017-01-09  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unindenting text inside a blockquote can result in the text being reordered
</span></span></pre></div>
<a id="trunkSourceWebCorepageSecurityOrigincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/SecurityOrigin.cpp (210530 => 210531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/SecurityOrigin.cpp        2017-01-10 00:15:11 UTC (rev 210530)
+++ trunk/Source/WebCore/page/SecurityOrigin.cpp        2017-01-10 00:32:24 UTC (rev 210531)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2007-2016 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2007-2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -229,19 +229,22 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (canAccess &amp;&amp; isLocal())
</span><del>-       canAccess = passesFileCheck(other);
</del><ins>+        canAccess = passesFileCheck(*other);
</ins><span class="cx"> 
</span><span class="cx">     return canAccess;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool SecurityOrigin::passesFileCheck(const SecurityOrigin* other) const
</del><ins>+bool SecurityOrigin::passesFileCheck(const SecurityOrigin&amp; other) const
</ins><span class="cx"> {
</span><del>-    ASSERT(isLocal() &amp;&amp; other-&gt;isLocal());
</del><ins>+    ASSERT(isLocal() &amp;&amp; other.isLocal());
</ins><span class="cx"> 
</span><del>-    if (!m_enforceFilePathSeparation &amp;&amp; !other-&gt;m_enforceFilePathSeparation)
</del><ins>+    if (!filesHaveSameVolume(m_filePath, other.m_filePath))
+        return false;
+
+    if (!m_enforceFilePathSeparation &amp;&amp; !other.m_enforceFilePathSeparation)
</ins><span class="cx">         return true;
</span><span class="cx"> 
</span><del>-    return (m_filePath == other-&gt;m_filePath);
</del><ins>+    return (m_filePath == other.m_filePath);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool SecurityOrigin::canRequest(const URL&amp; url) const
</span><span class="lines">@@ -304,6 +307,11 @@
</span><span class="cx">     if (m_universalAccess)
</span><span class="cx">         return true;
</span><span class="cx"> 
</span><ins>+    if (isLocal() &amp;&amp; url.isLocalFile()) {
+        if (!filesHaveSameVolume(m_filePath, url.path()))
+            return false;
+    }
+
</ins><span class="cx">     if (isFeedWithNestedProtocolInHTTPFamily(url))
</span><span class="cx">         return true;
</span><span class="cx"> 
</span><span class="lines">@@ -523,7 +531,7 @@
</span><span class="cx">     if (m_port != other-&gt;m_port)
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    if (isLocal() &amp;&amp; !passesFileCheck(other))
</del><ins>+    if (isLocal() &amp;&amp; !passesFileCheck(*other))
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     return true;
</span></span></pre></div>
<a id="trunkSourceWebCorepageSecurityOriginh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/SecurityOrigin.h (210530 => 210531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/SecurityOrigin.h        2017-01-10 00:15:11 UTC (rev 210530)
+++ trunk/Source/WebCore/page/SecurityOrigin.h        2017-01-10 00:32:24 UTC (rev 210531)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2007-2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -208,7 +208,7 @@
</span><span class="cx">     explicit SecurityOrigin(const SecurityOrigin*);
</span><span class="cx"> 
</span><span class="cx">     // FIXME: Rename this function to something more semantic.
</span><del>-    bool passesFileCheck(const SecurityOrigin*) const;
</del><ins>+    bool passesFileCheck(const SecurityOrigin&amp;) const;
</ins><span class="cx"> 
</span><span class="cx">     // This method checks that the scheme for this origin is an HTTP-family
</span><span class="cx">     // scheme, e.g. HTTP and HTTPS.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformFileSystemcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/FileSystem.cpp (210530 => 210531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/FileSystem.cpp        2017-01-10 00:15:11 UTC (rev 210530)
+++ trunk/Source/WebCore/platform/FileSystem.cpp        2017-01-10 00:32:24 UTC (rev 210531)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2007, 2011 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2007-2017 Apple Inc. All rights reserved.
</ins><span class="cx">  * Copyright (C) 2015 Canon Inc. All rights reserved.
</span><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="lines">@@ -233,6 +233,39 @@
</span><span class="cx">     ASSERT_NOT_REACHED();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+    
+bool filesHaveSameVolume(const String&amp; fileA, const String&amp; fileB)
+{
+    auto fsRepFileA = fileSystemRepresentation(fileA);
+    auto fsRepFileB = fileSystemRepresentation(fileB);
+    
+    if (fsRepFileA.isNull() || fsRepFileB.isNull())
+        return false;
+
+    auto handleA = openFile(fsRepFileA.data(), OpenForRead);
+    if (!isHandleValid(handleA))
+        return false;
+
+    auto handleB = openFile(fsRepFileB.data(), OpenForRead);
+    if (!isHandleValid(handleB)) {
+        closeFile(handleA);
+        return false;
+    }
+
+    bool result = false;
+
+    auto fileADev = getFileDeviceId(handleA);
+    auto fileBDev = getFileDeviceId(handleB);
+
+    if (fileADev &amp;&amp; fileBDev)
+        result = (fileADev == fileBDev);
+    
+    closeFile(handleA);
+    closeFile(handleB);
+    
+    return result;
+}
+
</ins><span class="cx"> #if !PLATFORM(MAC)
</span><span class="cx"> 
</span><span class="cx"> void setMetadataURL(String&amp;, const String&amp;, const String&amp;)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformFileSystemh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/FileSystem.h (210530 => 210531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/FileSystem.h        2017-01-10 00:15:11 UTC (rev 210530)
+++ trunk/Source/WebCore/platform/FileSystem.h        2017-01-10 00:32:24 UTC (rev 210531)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2007, 2008, 2011 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2007-2017 Apple Inc. All rights reserved.
</ins><span class="cx">  * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
</span><span class="cx">  * Copyright (C) 2015 Canon Inc. All rights reserved.
</span><span class="cx">  *
</span><span class="lines">@@ -146,6 +146,7 @@
</span><span class="cx"> WEBCORE_EXPORT String pathGetFileName(const String&amp;);
</span><span class="cx"> WEBCORE_EXPORT String directoryName(const String&amp;);
</span><span class="cx"> WEBCORE_EXPORT bool getVolumeFreeSpace(const String&amp;, uint64_t&amp;);
</span><ins>+WEBCORE_EXPORT std::optional&lt;int32_t&gt; getFileDeviceId(PlatformFileHandle);
</ins><span class="cx"> 
</span><span class="cx"> WEBCORE_EXPORT void setMetadataURL(String&amp; URLString, const String&amp; referrer, const String&amp; path);
</span><span class="cx"> 
</span><span class="lines">@@ -193,6 +194,8 @@
</span><span class="cx"> WEBCORE_EXPORT String encodeForFileName(const String&amp;);
</span><span class="cx"> String decodeFromFilename(const String&amp;);
</span><span class="cx"> 
</span><ins>+bool filesHaveSameVolume(const String&amp;, const String&amp;);
+
</ins><span class="cx"> #if USE(CF)
</span><span class="cx"> RetainPtr&lt;CFURLRef&gt; pathAsURL(const String&amp;);
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkcocoaResourceRequestCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm (210530 => 210531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm        2017-01-10 00:15:11 UTC (rev 210530)
+++ trunk/Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm        2017-01-10 00:32:24 UTC (rev 210531)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2014 Apple, Inc.  All rights reserved.
</del><ins>+ * Copyright (C) 2014-2017 Apple, Inc.  All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx"> 
</span><ins>+#import &quot;FileSystem.h&quot;
</ins><span class="cx"> #import &quot;FormDataStreamMac.h&quot;
</span><span class="cx"> #import &quot;HTTPHeaderNames.h&quot;
</span><span class="cx"> #import &quot;ResourceRequestCFNet.h&quot;
</span><span class="lines">@@ -203,6 +204,20 @@
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if (PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101200)
+    if (m_url.isLocalFile()) {
+        auto fsRepFile = fileSystemRepresentation(m_url.fileSystemPath());
+        if (!fsRepFile.isNull()) {
+            auto handle = openFile(fsRepFile.data(), OpenForRead);
+            if (isHandleValid(handle)) {
+                auto fileDevice = getFileDeviceId(handle);
+                if (fileDevice &amp;&amp; fileDevice.value())
+                    [nsRequest _setProperty:[NSNumber numberWithInteger:fileDevice.value()] forKey:@&quot;NSURLRequestFileProtocolExpectedDevice&quot;];
+            }
+        }
+    }
+#endif
+
</ins><span class="cx">     m_nsRequest = adoptNS(nsRequest);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformposixFileSystemPOSIXcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/posix/FileSystemPOSIX.cpp (210530 => 210531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/posix/FileSystemPOSIX.cpp        2017-01-10 00:15:11 UTC (rev 210530)
+++ trunk/Source/WebCore/platform/posix/FileSystemPOSIX.cpp        2017-01-10 00:32:24 UTC (rev 210531)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2007-2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -383,4 +383,13 @@
</span><span class="cx">     return appendResult;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+std::optional&lt;int32_t&gt; getFileDeviceId(PlatformFileHandle handle)
+{
+    struct stat fileStat;
+    if (fstat(handle, &amp;fileStat))
+        return std::nullopt;
+
+    return fileStat.st_dev;
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformwinFileSystemWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/win/FileSystemWin.cpp (210530 => 210531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/win/FileSystemWin.cpp        2017-01-10 00:15:11 UTC (rev 210530)
+++ trunk/Source/WebCore/platform/win/FileSystemWin.cpp        2017-01-10 00:32:24 UTC (rev 210531)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2007-2017 Apple Inc. All rights reserved.
</ins><span class="cx">  * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
</span><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="lines">@@ -33,13 +33,15 @@
</span><span class="cx"> #include &quot;FileMetadata.h&quot;
</span><span class="cx"> #include &quot;NotImplemented.h&quot;
</span><span class="cx"> #include &quot;PathWalker.h&quot;
</span><ins>+#include &lt;io.h&gt;
+#include &lt;shlobj.h&gt;
+#include &lt;shlwapi.h&gt;
+#include &lt;sys/stat.h&gt;
+#include &lt;windows.h&gt;
</ins><span class="cx"> #include &lt;wtf/CryptographicallyRandomNumber.h&gt;
</span><span class="cx"> #include &lt;wtf/HashMap.h&gt;
</span><span class="cx"> #include &lt;wtf/text/CString.h&gt;
</span><span class="cx"> 
</span><del>-#include &lt;windows.h&gt;
-#include &lt;shlobj.h&gt;
-#include &lt;shlwapi.h&gt;
</del><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -452,4 +454,13 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+std::optional&lt;int32_t&gt; getFileDeviceId(PlatformFileHandle handle)
+{
+    BY_HANDLE_FILE_INFORMATION fileInformation = { };
+    if (!::GetFileInformationByHandle(handle, &amp;fileInformation))
+        return std::nullopt;
+
+    return fileInformation.dwVolumeSerialNumber;
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (210530 => 210531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2017-01-10 00:15:11 UTC (rev 210530)
+++ trunk/Tools/ChangeLog        2017-01-10 00:32:24 UTC (rev 210531)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2017-01-09  Brent Fulgham  &lt;bfulgham@apple.com&gt;
+
+        File scheme should not allow access of a resource on a different volume.
+        https://bugs.webkit.org/show_bug.cgi?id=158552
+        &lt;rdar://problem/15307582&gt;
+
+        Reviewed by Alex Christensen.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Add new files.
+        * TestWebKitAPI/Tests/mac/CrossPartitionFileSchemeAccess.html: Added.
+        * TestWebKitAPI/Tests/mac/CrossPartitionFileSchemeAccess.mm: Added.
+
</ins><span class="cx"> 2017-01-09  Carlos Alberto Lopez Perez  &lt;clopez@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GTK][Wayland] Allow running the layout tests under a native Wayland environment.
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (210530 => 210531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2017-01-10 00:15:11 UTC (rev 210530)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2017-01-10 00:32:24 UTC (rev 210531)
</span><span class="lines">@@ -197,6 +197,8 @@
</span><span class="cx">                 7A909A831D877480007E10F8 /* IntSize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A909A751D877475007E10F8 /* IntSize.cpp */; };
</span><span class="cx">                 7AD3FE8E1D76131200B169A4 /* TransformationMatrix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AD3FE8D1D75FB8D00B169A4 /* TransformationMatrix.cpp */; };
</span><span class="cx">                 7AE9E5091AE5AE8B00CF874B /* test.pdf in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7AE9E5081AE5AE8B00CF874B /* test.pdf */; };
</span><ins>+                7AEAD47F1E20116C00416EFE /* CrossPartitionFileSchemeAccess.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7AEAD47C1E20113800416EFE /* CrossPartitionFileSchemeAccess.mm */; };
+                7AEAD4811E20122700416EFE /* CrossPartitionFileSchemeAccess.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7AEAD47D1E20114E00416EFE /* CrossPartitionFileSchemeAccess.html */; };
</ins><span class="cx">                 7C3965061CDD74F90094DBB8 /* Color.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C3965051CDD74F90094DBB8 /* Color.cpp */; };
</span><span class="cx">                 7C3DB8E41D12129B00AE8CC3 /* CommandBackForward.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7C3DB8E21D12129B00AE8CC3 /* CommandBackForward.mm */; };
</span><span class="cx">                 7C417F331D19E14800B8EF53 /* WKWebViewDefaultNavigationDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7C417F311D19E14800B8EF53 /* WKWebViewDefaultNavigationDelegate.mm */; };
</span><span class="lines">@@ -601,6 +603,7 @@
</span><span class="cx">                         dstPath = TestWebKitAPI.resources;
</span><span class="cx">                         dstSubfolderSpec = 7;
</span><span class="cx">                         files = (
</span><ins>+                                7AEAD4811E20122700416EFE /* CrossPartitionFileSchemeAccess.html in Copy Resources */,
</ins><span class="cx">                                 CDB4115A1E0B00DB00EAD352 /* video-with-muted-audio.html in Copy Resources */,
</span><span class="cx">                                 9BD4239C1E04C01C00200395 /* chinese-character-with-image.html in Copy Resources */,
</span><span class="cx">                                 A155022C1E050D0300A24C57 /* duplicate-completion-handler-calls.html in Copy Resources */,
</span><span class="lines">@@ -1040,6 +1043,8 @@
</span><span class="cx">                 7AA6A1511AAC0B31002B2ED3 /* WorkQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkQueue.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7AD3FE8D1D75FB8D00B169A4 /* TransformationMatrix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TransformationMatrix.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7AE9E5081AE5AE8B00CF874B /* test.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = test.pdf; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                7AEAD47C1E20113800416EFE /* CrossPartitionFileSchemeAccess.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CrossPartitionFileSchemeAccess.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
+                7AEAD47D1E20114E00416EFE /* CrossPartitionFileSchemeAccess.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = CrossPartitionFileSchemeAccess.html; path = Tests/mac/CrossPartitionFileSchemeAccess.html; sourceTree = SOURCE_ROOT; };
</ins><span class="cx">                 7C3965051CDD74F90094DBB8 /* Color.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Color.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7C3DB8E21D12129B00AE8CC3 /* CommandBackForward.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CommandBackForward.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7C417F311D19E14800B8EF53 /* WKWebViewDefaultNavigationDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewDefaultNavigationDelegate.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -2029,6 +2034,7 @@
</span><span class="cx">                 C07E6CAD13FD67650038B22B /* mac */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                7AEAD47C1E20113800416EFE /* CrossPartitionFileSchemeAccess.mm */,
</ins><span class="cx">                                 5C0BF88F1DD5999B00B00328 /* WebViewCanPasteZeroPng.mm */,
</span><span class="cx">                                 5C0BF88C1DD5957400B00328 /* MemoryPressureHandler.mm */,
</span><span class="cx">                                 C07E6CB013FD737C0038B22B /* Resources */,
</span><span class="lines">@@ -2093,6 +2099,7 @@
</span><span class="cx">                 C07E6CB013FD737C0038B22B /* Resources */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                7AEAD47D1E20114E00416EFE /* CrossPartitionFileSchemeAccess.html */,
</ins><span class="cx">                                 F42DA5151D8CEFDB00336F40 /* large-input-field-focus-onload.html */,
</span><span class="cx">                                 379028B814FABE49007E6B43 /* acceptsFirstMouse.html */,
</span><span class="cx">                                 B55F11B9151916E600915916 /* Ahem.ttf */,
</span><span class="lines">@@ -2497,6 +2504,7 @@
</span><span class="cx">                                 2DC4CF771D2D9DD800ECCC94 /* DataDetection.mm in Sources */,
</span><span class="cx">                                 2D1646E21D1862CD00015A1A /* DeferredViewInWindowStateChange.mm in Sources */,
</span><span class="cx">                                 7CCE7EB91A411A7E00447C4C /* DeviceScaleFactorInDashboardRegions.mm in Sources */,
</span><ins>+                                7AEAD47F1E20116C00416EFE /* CrossPartitionFileSchemeAccess.mm in Sources */,
</ins><span class="cx">                                 7CCE7EBA1A411A7E00447C4C /* DeviceScaleFactorOnBack.mm in Sources */,
</span><span class="cx">                                 7C83E04D1D0A641800FEBCF3 /* DFACombiner.cpp in Sources */,
</span><span class="cx">                                 7C83E04E1D0A641800FEBCF3 /* DFAMinimizer.cpp in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsmacCrossPartitionFileSchemeAccesshtml"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/mac/CrossPartitionFileSchemeAccess.html (0 => 210531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/mac/CrossPartitionFileSchemeAccess.html                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/CrossPartitionFileSchemeAccess.html        2017-01-10 00:32:24 UTC (rev 210531)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;script&gt;
+    var check = 0;
+    function iframeLoaded() {
+        check = 1;
+    }
+    function documentLoaded() {
+        if (check == 1)
+            document.write(&quot;Fail: A cross partition resource was loaded&quot;);
+        else
+            document.write(&quot;Pass: A cross partition resource was blocked from loading&quot;);
+    }
+&lt;/script&gt;
+&lt;body onload=&quot;documentLoaded()&quot;&gt;
+    &lt;iframe src=&quot;file:///Volumes/resources/CrossPartitionFileSchemeAccess.html&quot; onload=&quot;iframeLoaded();&quot;&gt;&lt;/iframe&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsmacCrossPartitionFileSchemeAccessmm"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/mac/CrossPartitionFileSchemeAccess.mm (0 => 210531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/mac/CrossPartitionFileSchemeAccess.mm                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/CrossPartitionFileSchemeAccess.mm        2017-01-10 00:32:24 UTC (rev 210531)
</span><span class="lines">@@ -0,0 +1,104 @@
</span><ins>+/*
+ * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import &quot;config.h&quot;
+
+#import &quot;PlatformUtilities.h&quot;
+#import &quot;WKWebViewConfigurationExtras.h&quot;
+#import &lt;WebKit/WKFoundation.h&gt;
+#import &lt;WebKit/WKWebViewPrivate.h&gt;
+#import &lt;WebKit/WebKit.h&gt;
+#import &lt;wtf/RetainPtr.h&gt;
+
+const char* successfulResult = &quot;Pass: A cross partition resource was blocked from loading&quot;;
+
+@interface CrossPartitionFileSchemeAccessNavigationDelegate : NSObject &lt;WKNavigationDelegate&gt;
+@end
+
+@implementation CrossPartitionFileSchemeAccessNavigationDelegate
+
+static bool navigationComplete = false;
+
+- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
+{
+    [webView evaluateJavaScript: @&quot;document.body.innerHTML&quot; completionHandler:^(NSString *result, NSError *error)
+    {
+        EXPECT_STREQ(successfulResult, [result UTF8String]);
+        navigationComplete = true;
+    }];
+}
+
+@end
+
+void createPartition(const char *filePath) 
+{
+    const char* fileContent = &quot; \&quot;&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;body&gt;Hello&lt;/body&gt;&lt;/html&gt;\&quot; &gt; &quot;;
+    const char* targetFile = &quot;resources/CrossPartitionFileSchemeAccess.html&quot;;
+    
+    const char* createDirCmd  = &quot;mkdir resources&quot;;
+    const char* createDiskImage = &quot;hdiutil create otherVolume.dmg -srcfolder resources/ -ov &gt; /dev/null&quot;;
+    const char* attachDiskImage = &quot;hdiutil attach otherVolume.dmg &gt; /dev/null&quot;;
+    
+    std::string createFileCmd = &quot;echo &quot;;
+    createFileCmd.append(fileContent);
+    createFileCmd.append(targetFile);
+    
+    system(createDirCmd);
+    system(createFileCmd.c_str());
+    system(createDiskImage);
+    system(attachDiskImage);
+}
+
+void cleanUp()
+{
+    const char* detachDiskImage = &quot;hdiutil detach /Volumes/resources &gt; /dev/null&quot;;
+    const char* deleteFolder = &quot;rm -rf resources/&quot;;
+    const char* deleteDiskImage = &quot;rm -rf otherVolume.dmg&quot;;
+    system(detachDiskImage);
+    system(deleteFolder);
+    system(deleteDiskImage);
+}
+
+
+namespace TestWebKitAPI {
+
+TEST(WebKit1, CrossPartitionFileSchemeAccess)
+{
+    NSURL *url = [[NSBundle mainBundle] URLForResource:@&quot;CrossPartitionFileSchemeAccess&quot; withExtension:@&quot;html&quot; subdirectory:@&quot;TestWebKitAPI.resources&quot;];
+    const char *filePath = [url fileSystemRepresentation];
+    createPartition(filePath);
+        
+    RetainPtr&lt;WKWebViewConfiguration&gt; configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    RetainPtr&lt;WKWebView&gt; webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+    
+    CrossPartitionFileSchemeAccessNavigationDelegate *delegate = [[CrossPartitionFileSchemeAccessNavigationDelegate alloc] init];
+    [webView setNavigationDelegate:delegate];
+    
+    NSURLRequest *request = [NSURLRequest requestWithURL:url];
+    [webView loadRequest:request];
+    Util::run(&amp;navigationComplete);
+    cleanUp();
+}
+}
</ins></span></pre>
</div>
</div>

</body>
</html>