Changeset 244964 in webkit


Ignore:
Timestamp:
May 6, 2019 10:23:13 AM (5 years ago)
Author:
Ryan Haddad
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

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r244955 r244964  
     12019-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
    1152019-05-04  Alex Christensen  <achristensen@webkit.org>
    216
  • trunk/Source/WebKit/Shared/Cocoa/SandboxExtensionCocoa.mm

    r244917 r244964  
    11/*
    2  * Copyright (C) 2010-2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3232#import "Decoder.h"
    3333#import "Encoder.h"
     34#import <sys/stat.h>
    3435#import <wtf/FileSystem.h>
    3536#import <wtf/spi/darwin/SandboxSPI.h>
     
    225226}
    226227
     228static 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
    227271String stringByResolvingSymlinksInPath(const String& path)
    228272{
    229     return [(NSString *)path stringByResolvingSymlinksInPath];
     273    return String::fromUTF8(resolveSymlinksInPath(path.utf8()));
    230274}
    231275
     
    245289String resolvePathForSandboxExtension(const String& path)
    246290{
    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());
    250295        return { };
    251296    }
    252297
    253     return resolvedPath;
     298    CString standardizedPath = resolveSymlinksInPath(fileSystemPath);
     299    return String::fromUTF8(standardizedPath);
    254300}
    255301
Note: See TracChangeset for help on using the changeset viewer.