Title: [244964] trunk/Source/WebKit
- Revision
- 244964
- Author
- ryanhad...@apple.com
- Date
- 2019-05-06 10:23:13 -0700 (Mon, 06 May 2019)
Log Message
Unreviewed, rolling out r244917.
Caused
TestWebKitAPI.WKWebView.InitializingWebViewWithEphemeralStorageDoesNotLog
failure on debug bots.
Reverted changeset:
"Use more efficient path resolution logic"
https://bugs.webkit.org/show_bug.cgi?id=197389
https://trac.webkit.org/changeset/244917
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (244963 => 244964)
--- trunk/Source/WebKit/ChangeLog 2019-05-06 17:07:06 UTC (rev 244963)
+++ trunk/Source/WebKit/ChangeLog 2019-05-06 17:23:13 UTC (rev 244964)
@@ -1,3 +1,17 @@
+2019-05-06 Ryan Haddad <ryanhad...@apple.com>
+
+ Unreviewed, rolling out r244917.
+
+ Caused
+ TestWebKitAPI.WKWebView.InitializingWebViewWithEphemeralStorageDoesNotLog
+ failure on debug bots.
+
+ Reverted changeset:
+
+ "Use more efficient path resolution logic"
+ https://bugs.webkit.org/show_bug.cgi?id=197389
+ https://trac.webkit.org/changeset/244917
+
2019-05-04 Alex Christensen <achristen...@webkit.org>
Revert r244953 and r244954 because they broke internal builds.
Modified: trunk/Source/WebKit/Shared/Cocoa/SandboxExtensionCocoa.mm (244963 => 244964)
--- trunk/Source/WebKit/Shared/Cocoa/SandboxExtensionCocoa.mm 2019-05-06 17:07:06 UTC (rev 244963)
+++ trunk/Source/WebKit/Shared/Cocoa/SandboxExtensionCocoa.mm 2019-05-06 17:23:13 UTC (rev 244964)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -31,6 +31,7 @@
#import "DataReference.h"
#import "Decoder.h"
#import "Encoder.h"
+#import <sys/stat.h>
#import <wtf/FileSystem.h>
#import <wtf/spi/darwin/SandboxSPI.h>
#import <wtf/text/CString.h>
@@ -224,9 +225,52 @@
return adoptRef(new SandboxExtension(handle));
}
+static CString resolveSymlinksInPath(const CString& path)
+{
+ struct stat statBuf;
+
+ // Check if this file exists.
+ if (!stat(path.data(), &statBuf)) {
+ char resolvedName[PATH_MAX];
+
+ return realpath(path.data(), resolvedName);
+ }
+
+ const char* slashPtr = strrchr(path.data(), '/');
+ if (slashPtr == path.data())
+ return path;
+
+ size_t parentDirectoryLength = slashPtr - path.data();
+ if (parentDirectoryLength >= PATH_MAX)
+ return CString();
+
+ // Get the parent directory.
+ char parentDirectory[PATH_MAX];
+ memcpy(parentDirectory, path.data(), parentDirectoryLength);
+ parentDirectory[parentDirectoryLength] = '\0';
+
+ // Resolve it.
+ CString resolvedParentDirectory = resolveSymlinksInPath(CString(parentDirectory));
+ if (resolvedParentDirectory.isNull())
+ return CString();
+
+ size_t lastPathComponentLength = path.length() - parentDirectoryLength;
+ size_t resolvedPathLength = resolvedParentDirectory.length() + lastPathComponentLength;
+ if (resolvedPathLength >= PATH_MAX)
+ return CString();
+
+ // Combine the resolved parent directory with the last path component.
+ char* resolvedPathBuffer;
+ CString resolvedPath = CString::newUninitialized(resolvedPathLength, resolvedPathBuffer);
+ memcpy(resolvedPathBuffer, resolvedParentDirectory.data(), resolvedParentDirectory.length());
+ memcpy(resolvedPathBuffer + resolvedParentDirectory.length(), slashPtr, lastPathComponentLength);
+
+ return resolvedPath;
+}
+
String stringByResolvingSymlinksInPath(const String& path)
{
- return [(NSString *)path stringByResolvingSymlinksInPath];
+ return String::fromUTF8(resolveSymlinksInPath(path.utf8()));
}
String resolveAndCreateReadWriteDirectoryForSandboxExtension(const String& path)
@@ -244,13 +288,15 @@
String resolvePathForSandboxExtension(const String& path)
{
- String resolvedPath = stringByResolvingSymlinksInPath(path);
- if (resolvedPath.isEmpty()) {
- LOG_ERROR("Could not create a valid file system representation for the string '%s' of length %lu", resolvedPath.utf8().data(), resolvedPath.length());
+ // FIXME: Do we need both resolveSymlinksInPath() and -stringByStandardizingPath?
+ CString fileSystemPath = FileSystem::fileSystemRepresentation([(NSString *)path stringByStandardizingPath]);
+ if (fileSystemPath.isNull()) {
+ LOG_ERROR("Could not create a valid file system representation for the string '%s' of length %lu", fileSystemPath.data(), fileSystemPath.length());
return { };
}
- return resolvedPath;
+ CString standardizedPath = resolveSymlinksInPath(fileSystemPath);
+ return String::fromUTF8(standardizedPath);
}
bool SandboxExtension::createHandleWithoutResolvingPath(const String& path, Type type, Handle& handle)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes