Changeset 244964 in webkit
- Timestamp:
- May 6, 2019 10:23:13 AM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r244955 r244964 1 2019-05-06 Ryan Haddad <ryanhaddad@apple.com> 2 3 Unreviewed, rolling out r244917. 4 5 Caused 6 TestWebKitAPI.WKWebView.InitializingWebViewWithEphemeralStorageDoesNotLog 7 failure on debug bots. 8 9 Reverted changeset: 10 11 "Use more efficient path resolution logic" 12 https://bugs.webkit.org/show_bug.cgi?id=197389 13 https://trac.webkit.org/changeset/244917 14 1 15 2019-05-04 Alex Christensen <achristensen@webkit.org> 2 16 -
trunk/Source/WebKit/Shared/Cocoa/SandboxExtensionCocoa.mm
r244917 r244964 1 1 /* 2 * Copyright (C) 2010-201 9Apple Inc. All rights reserved.2 * Copyright (C) 2010-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 32 32 #import "Decoder.h" 33 33 #import "Encoder.h" 34 #import <sys/stat.h> 34 35 #import <wtf/FileSystem.h> 35 36 #import <wtf/spi/darwin/SandboxSPI.h> … … 225 226 } 226 227 228 static CString resolveSymlinksInPath(const CString& path) 229 { 230 struct stat statBuf; 231 232 // Check if this file exists. 233 if (!stat(path.data(), &statBuf)) { 234 char resolvedName[PATH_MAX]; 235 236 return realpath(path.data(), resolvedName); 237 } 238 239 const char* slashPtr = strrchr(path.data(), '/'); 240 if (slashPtr == path.data()) 241 return path; 242 243 size_t parentDirectoryLength = slashPtr - path.data(); 244 if (parentDirectoryLength >= PATH_MAX) 245 return CString(); 246 247 // Get the parent directory. 248 char parentDirectory[PATH_MAX]; 249 memcpy(parentDirectory, path.data(), parentDirectoryLength); 250 parentDirectory[parentDirectoryLength] = '\0'; 251 252 // Resolve it. 253 CString resolvedParentDirectory = resolveSymlinksInPath(CString(parentDirectory)); 254 if (resolvedParentDirectory.isNull()) 255 return CString(); 256 257 size_t lastPathComponentLength = path.length() - parentDirectoryLength; 258 size_t resolvedPathLength = resolvedParentDirectory.length() + lastPathComponentLength; 259 if (resolvedPathLength >= PATH_MAX) 260 return CString(); 261 262 // Combine the resolved parent directory with the last path component. 263 char* resolvedPathBuffer; 264 CString resolvedPath = CString::newUninitialized(resolvedPathLength, resolvedPathBuffer); 265 memcpy(resolvedPathBuffer, resolvedParentDirectory.data(), resolvedParentDirectory.length()); 266 memcpy(resolvedPathBuffer + resolvedParentDirectory.length(), slashPtr, lastPathComponentLength); 267 268 return resolvedPath; 269 } 270 227 271 String stringByResolvingSymlinksInPath(const String& path) 228 272 { 229 return [(NSString *)path stringByResolvingSymlinksInPath];273 return String::fromUTF8(resolveSymlinksInPath(path.utf8())); 230 274 } 231 275 … … 245 289 String resolvePathForSandboxExtension(const String& path) 246 290 { 247 String resolvedPath = stringByResolvingSymlinksInPath(path); 248 if (resolvedPath.isEmpty()) { 249 LOG_ERROR("Could not create a valid file system representation for the string '%s' of length %lu", resolvedPath.utf8().data(), resolvedPath.length()); 291 // FIXME: Do we need both resolveSymlinksInPath() and -stringByStandardizingPath? 292 CString fileSystemPath = FileSystem::fileSystemRepresentation([(NSString *)path stringByStandardizingPath]); 293 if (fileSystemPath.isNull()) { 294 LOG_ERROR("Could not create a valid file system representation for the string '%s' of length %lu", fileSystemPath.data(), fileSystemPath.length()); 250 295 return { }; 251 296 } 252 297 253 return resolvedPath; 298 CString standardizedPath = resolveSymlinksInPath(fileSystemPath); 299 return String::fromUTF8(standardizedPath); 254 300 } 255 301
Note: See TracChangeset
for help on using the changeset viewer.