Diff
Modified: trunk/Source/WTF/ChangeLog (230034 => 230035)
--- trunk/Source/WTF/ChangeLog 2018-03-28 17:53:21 UTC (rev 230034)
+++ trunk/Source/WTF/ChangeLog 2018-03-28 18:07:00 UTC (rev 230035)
@@ -1,3 +1,22 @@
+2018-03-28 Brent Fulgham <[email protected]>
+
+ Avoid uninitialized mach ports
+ https://bugs.webkit.org/show_bug.cgi?id=184090
+ <rdar://problem/37261129>
+
+ Reviewed by Chris Dumez.
+
+ It is possible for mach_port_allocate to return an error, but we rarely check its return value. The value
+ of the argument passed to mach_port_allocate is not guaranteed to be valid when it returns an error, so
+ there is a potential for us to try to use invalid ports.
+
+ We should always check return values, and ensure that the mach port variables we seek to initialize are
+ kept in a valid state.
+
+ Reviewed by Chris Dumez.
+
+ * wtf/Threading.h: Initialize mach port.
+
2018-03-28 Robin Morisset <[email protected]>
appendQuotedJSONString stops on arithmetic overflow instead of propagating it upwards
Modified: trunk/Source/WTF/wtf/Threading.h (230034 => 230035)
--- trunk/Source/WTF/wtf/Threading.h 2018-03-28 17:53:21 UTC (rev 230034)
+++ trunk/Source/WTF/wtf/Threading.h 2018-03-28 18:07:00 UTC (rev 230035)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2018 Apple Inc. All rights reserved.
* Copyright (C) 2007 Justin Haygood <[email protected]>
* Copyright (C) 2017 Yusuke Suzuki <[email protected]>
*
@@ -281,7 +281,7 @@
#if OS(WINDOWS)
ThreadIdentifier m_id { 0 };
#elif OS(DARWIN)
- mach_port_t m_platformThread;
+ mach_port_t m_platformThread { MACH_PORT_NULL };
#elif USE(PTHREADS)
PlatformRegisters* m_platformRegisters { nullptr };
unsigned m_suspendCount { 0 };
Modified: trunk/Source/WebCore/ChangeLog (230034 => 230035)
--- trunk/Source/WebCore/ChangeLog 2018-03-28 17:53:21 UTC (rev 230034)
+++ trunk/Source/WebCore/ChangeLog 2018-03-28 18:07:00 UTC (rev 230035)
@@ -1,3 +1,23 @@
+2018-03-28 Brent Fulgham <[email protected]>
+
+ Avoid uninitialized mach ports
+ https://bugs.webkit.org/show_bug.cgi?id=184090
+ <rdar://problem/37261129>
+
+ Reviewed by Chris Dumez.
+
+ It is possible for mach_port_allocate to return an error, but we rarely check its return value. The value
+ of the argument passed to mach_port_allocate is not guaranteed to be valid when it returns an error, so
+ there is a potential for us to try to use invalid ports.
+
+ We should always check return values, and ensure that the mach port variables we seek to initialize are
+ kept in a valid state.
+
+ No new tests, no Web-facing behavior change.
+
+ * platform/graphics/cocoa/GraphicsContext3DCocoa.mm:
+ (WebCore::attachToAppleGraphicsControl): Initialize masterPort to a default value.
+
2018-03-28 Antoine Quint <[email protected]>
[Web Animations] Implement more CSSPropertyBlendingClient methods
Modified: trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm (230034 => 230035)
--- trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm 2018-03-28 17:53:21 UTC (rev 230034)
+++ trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm 2018-03-28 18:07:00 UTC (rev 230035)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2009-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -77,7 +77,7 @@
static io_connect_t attachToAppleGraphicsControl()
{
- mach_port_t masterPort;
+ mach_port_t masterPort = MACH_PORT_NULL;
if (IOMasterPort(MACH_PORT_NULL, &masterPort) != KERN_SUCCESS)
return MACH_PORT_NULL;
Modified: trunk/Source/WebKit/ChangeLog (230034 => 230035)
--- trunk/Source/WebKit/ChangeLog 2018-03-28 17:53:21 UTC (rev 230034)
+++ trunk/Source/WebKit/ChangeLog 2018-03-28 18:07:00 UTC (rev 230035)
@@ -1,3 +1,44 @@
+2018-03-28 Brent Fulgham <[email protected]>
+
+ Avoid uninitialized mach ports
+ https://bugs.webkit.org/show_bug.cgi?id=184090
+ <rdar://problem/37261129>
+
+ Reviewed by Chris Dumez.
+
+ It is possible for mach_port_allocate to return an error, but we rarely check its return value. The value
+ of the argument passed to mach_port_allocate is not guaranteed to be valid when it returns an error, so
+ there is a potential for us to try to use invalid ports.
+
+ We should always check return values, and ensure that the mach port variables we seek to initialize are
+ kept in a valid state.
+
+ Reviewed by Chris Dumez.
+
+ * NetworkProcess/NetworkProcess.cpp:
+ (WebKit::NetworkProcess::createNetworkConnectionToWebProcess): Initialize new port to a safe default and
+ check the return state of the allocation function.
+ * Platform/IPC/Connection.h:
+ * Platform/IPC/mac/ConnectionMac.mm:
+ (IPC::Connection::open): Ditto.
+ (IPC::Connection::initializeSendSource): Ditto.
+ (IPC::readFromMachPort): Ditto.
+ (IPC::Connection::receiveSourceEventHandler): Ditto.
+ * Platform/SharedMemory.h:
+ * Platform/cocoa/SharedMemoryCocoa.cpp:
+ (WebKit::makeMemoryEntry): Ditto.
+ * Platform/mac/MachUtilities.cpp:
+ (setMachPortQueueLength): Ditto.
+ (setMachExceptionPort): Ditto.
+ * PluginProcess/PluginProcess.cpp:
+ (WebKit::PluginProcess::createWebProcessConnection): Ditto.
+ * StorageProcess/StorageProcess.cpp:
+ (WebKit::StorageProcess::createStorageToWebProcessConnection): Ditto.
+ * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
+ (WebKit::ProcessLauncher::launchProcess): Ditto.
+ * WebProcess/WebPage/WebInspector.cpp:
+ (WebKit::WebInspector::openFrontendConnection): Ditto.
+
2018-03-28 Michael Catanzaro <[email protected]>
Fails to build webkitgtk+ after git-svn-id: http://svn.webkit.org/repository/webkit/trunk@229877 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp (230034 => 230035)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2018-03-28 17:53:21 UTC (rev 230034)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2018-03-28 18:07:00 UTC (rev 230035)
@@ -294,8 +294,12 @@
parentProcessConnection()->send(Messages::NetworkProcessProxy::DidCreateNetworkConnectionToWebProcess(clientSocket), 0);
#elif OS(DARWIN)
// Create the listening port.
- mach_port_t listeningPort;
- mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &listeningPort);
+ mach_port_t listeningPort = MACH_PORT_NULL;
+ auto kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &listeningPort);
+ if (kr != KERN_SUCCESS) {
+ LOG_ERROR("Could not allocate mach port, error %x", kr);
+ CRASH();
+ }
// Create a listening connection.
auto connection = NetworkConnectionToWebProcess::create(IPC::Connection::Identifier(listeningPort));
Modified: trunk/Source/WebKit/Platform/IPC/Connection.h (230034 => 230035)
--- trunk/Source/WebKit/Platform/IPC/Connection.h 2018-03-28 17:53:21 UTC (rev 230034)
+++ trunk/Source/WebKit/Platform/IPC/Connection.h 2018-03-28 18:07:00 UTC (rev 230035)
@@ -328,11 +328,11 @@
void receiveSourceEventHandler();
void initializeSendSource();
- mach_port_t m_sendPort;
- dispatch_source_t m_sendSource;
+ mach_port_t m_sendPort { MACH_PORT_NULL };
+ dispatch_source_t m_sendSource { nullptr };
- mach_port_t m_receivePort;
- dispatch_source_t m_receiveSource;
+ mach_port_t m_receivePort { MACH_PORT_NULL };
+ dispatch_source_t m_receiveSource { nullptr };
std::unique_ptr<MachMessage> m_pendingOutgoingMachMessage;
Modified: trunk/Source/WebKit/Platform/IPC/mac/ConnectionMac.mm (230034 => 230035)
--- trunk/Source/WebKit/Platform/IPC/mac/ConnectionMac.mm 2018-03-28 17:53:21 UTC (rev 230034)
+++ trunk/Source/WebKit/Platform/IPC/mac/ConnectionMac.mm 2018-03-28 18:07:00 UTC (rev 230035)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -184,7 +184,11 @@
ASSERT(!m_receivePort);
ASSERT(m_sendPort);
- mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &m_receivePort);
+ auto kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &m_receivePort);
+ if (kr != KERN_SUCCESS) {
+ LOG_ERROR("Could not allocate mach port, error %x", kr);
+ CRASH();
+ }
#if !PLATFORM(WATCHOS)
mach_port_guard(mach_task_self(), m_receivePort, reinterpret_cast<mach_port_context_t>(this), true);
#endif
@@ -383,6 +387,7 @@
}
});
+ ASSERT(MACH_PORT_VALID(m_sendPort));
mach_port_t sendPort = m_sendPort;
dispatch_source_set_cancel_handler(m_sendSource, ^{
// Release our send right.
@@ -455,12 +460,14 @@
static mach_msg_header_t* readFromMachPort(mach_port_t machPort, ReceiveBuffer& buffer)
{
+ ASSERT(MACH_PORT_VALID(machPort));
+
buffer.resize(receiveBufferSize);
mach_msg_header_t* header = reinterpret_cast<mach_msg_header_t*>(buffer.data());
kern_return_t kr = mach_msg(header, MACH_RCV_MSG | MACH_RCV_LARGE | MACH_RCV_TIMEOUT, 0, buffer.size(), machPort, 0, MACH_PORT_NULL);
if (kr == MACH_RCV_TIMED_OUT)
- return 0;
+ return nullptr;
if (kr == MACH_RCV_TOO_LARGE) {
// The message was too large, resize the buffer and try again.
@@ -476,7 +483,7 @@
WebKit::setCrashReportApplicationSpecificInformation((CFStringRef)[NSString stringWithFormat:@"Unhandled error code %x from mach_msg, receive port is %x", kr, machPort]);
#endif
ASSERT_NOT_REACHED();
- return 0;
+ return nullptr;
}
return header;
@@ -525,7 +532,7 @@
m_sendPort = port.port();
if (m_sendPort) {
- mach_port_t previousNotificationPort;
+ mach_port_t previousNotificationPort = MACH_PORT_NULL;
mach_port_request_notification(mach_task_self(), m_receivePort, MACH_NOTIFY_NO_SENDERS, 0, MACH_PORT_NULL, MACH_MSG_TYPE_MOVE_SEND_ONCE, &previousNotificationPort);
if (previousNotificationPort != MACH_PORT_NULL)
Modified: trunk/Source/WebKit/Platform/SharedMemory.h (230034 => 230035)
--- trunk/Source/WebKit/Platform/SharedMemory.h 2018-03-28 17:53:21 UTC (rev 230034)
+++ trunk/Source/WebKit/Platform/SharedMemory.h 2018-03-28 18:07:00 UTC (rev 230035)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
* Copyright (C) 2017 Sony Interactive Entertainment Inc.
*
* Redistribution and use in source and binary forms, with or without
@@ -81,7 +81,7 @@
#if USE(UNIX_DOMAIN_SOCKETS)
mutable IPC::Attachment m_attachment;
#elif OS(DARWIN)
- mutable mach_port_t m_port;
+ mutable mach_port_t m_port { MACH_PORT_NULL };
size_t m_size;
#elif OS(WINDOWS)
mutable HANDLE m_handle;
@@ -132,7 +132,7 @@
std::optional<int> m_fileDescriptor;
bool m_isWrappingMap { false };
#elif OS(DARWIN)
- mach_port_t m_port;
+ mach_port_t m_port { MACH_PORT_NULL };
#elif OS(WINDOWS)
HANDLE m_handle;
#endif
Modified: trunk/Source/WebKit/Platform/cocoa/SharedMemoryCocoa.cpp (230034 => 230035)
--- trunk/Source/WebKit/Platform/cocoa/SharedMemoryCocoa.cpp 2018-03-28 17:53:21 UTC (rev 230034)
+++ trunk/Source/WebKit/Platform/cocoa/SharedMemoryCocoa.cpp 2018-03-28 18:07:00 UTC (rev 230035)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -141,7 +141,7 @@
{
memory_object_size_t memoryObjectSize = round_page(size);
- mach_port_t port;
+ mach_port_t port = MACH_PORT_NULL;
kern_return_t kr = mach_make_memory_entry_64(mach_task_self(), &memoryObjectSize, offset, machProtection(protection) | VM_PROT_IS_MASK | MAP_MEM_VM_SHARE, &port, parentEntry);
if (kr != KERN_SUCCESS) {
#if RELEASE_LOG_DISABLED
Modified: trunk/Source/WebKit/Platform/mac/MachUtilities.cpp (230034 => 230035)
--- trunk/Source/WebKit/Platform/mac/MachUtilities.cpp 2018-03-28 17:53:21 UTC (rev 230034)
+++ trunk/Source/WebKit/Platform/mac/MachUtilities.cpp 2018-03-28 18:07:00 UTC (rev 230035)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2018 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,8 @@
void setMachPortQueueLength(mach_port_t receivePort, mach_port_msgcount_t queueLength)
{
+ ASSERT(MACH_PORT_VALID(receivePort));
+
mach_port_limits_t portLimits;
portLimits.mpl_qlimit = queueLength;
@@ -57,6 +59,8 @@
void setMachExceptionPort(mach_port_t exceptionPort)
{
+ ASSERT(MACH_PORT_VALID(exceptionPort));
+
// Assert that we dont try to call setMachExceptionPort more than once per process.
#if !ASSERT_DISABLED
static mach_port_t taskExceptionPort = MACH_PORT_NULL;
Modified: trunk/Source/WebKit/PluginProcess/PluginProcess.cpp (230034 => 230035)
--- trunk/Source/WebKit/PluginProcess/PluginProcess.cpp 2018-03-28 17:53:21 UTC (rev 230034)
+++ trunk/Source/WebKit/PluginProcess/PluginProcess.cpp 2018-03-28 18:07:00 UTC (rev 230035)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -162,8 +162,12 @@
parentProcessConnection()->send(Messages::PluginProcessProxy::DidCreateWebProcessConnection(clientSocket, m_supportsAsynchronousPluginInitialization), 0);
#elif OS(DARWIN)
// Create the listening port.
- mach_port_t listeningPort;
- mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &listeningPort);
+ mach_port_t listeningPort = MACH_PORT_NULL;
+ auto kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &listeningPort);
+ if (kr != KERN_SUCCESS) {
+ LOG_ERROR("Could not allocate mach port, error %x", kr);
+ CRASH();
+ }
// Create a listening connection.
auto connection = WebProcessConnection::create(IPC::Connection::Identifier(listeningPort));
Modified: trunk/Source/WebKit/StorageProcess/StorageProcess.cpp (230034 => 230035)
--- trunk/Source/WebKit/StorageProcess/StorageProcess.cpp 2018-03-28 17:53:21 UTC (rev 230034)
+++ trunk/Source/WebKit/StorageProcess/StorageProcess.cpp 2018-03-28 18:07:00 UTC (rev 230035)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013, 2014, 2015, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -259,8 +259,12 @@
parentProcessConnection()->send(Messages::StorageProcessProxy::DidCreateStorageToWebProcessConnection(IPC::Attachment(socketPair.client)), 0);
#elif OS(DARWIN)
// Create the listening port.
- mach_port_t listeningPort;
- mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &listeningPort);
+ mach_port_t listeningPort = MACH_PORT_NULL;
+ auto kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &listeningPort);
+ if (kr != KERN_SUCCESS) {
+ LOG_ERROR("Could not allocate mach port, error %x", kr);
+ CRASH();
+ }
// Create a listening connection.
m_storageToWebProcessConnections.append(StorageToWebProcessConnection::create(IPC::Connection::Identifier(listeningPort)));
Modified: trunk/Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm (230034 => 230035)
--- trunk/Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm 2018-03-28 17:53:21 UTC (rev 230034)
+++ trunk/Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm 2018-03-28 18:07:00 UTC (rev 230035)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -150,9 +150,13 @@
}
// Create the listening port.
- mach_port_t listeningPort;
- mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &listeningPort);
-
+ mach_port_t listeningPort = MACH_PORT_NULL;
+ auto kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &listeningPort);
+ if (kr != KERN_SUCCESS) {
+ LOG_ERROR("Could not allocate mach port, error %x", kr);
+ CRASH();
+ }
+
// Insert a send right so we can send to it.
mach_port_insert_right(mach_task_self(), listeningPort, listeningPort, MACH_MSG_TYPE_MAKE_SEND);
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebInspector.cpp (230034 => 230035)
--- trunk/Source/WebKit/WebProcess/WebPage/WebInspector.cpp 2018-03-28 17:53:21 UTC (rev 230034)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebInspector.cpp 2018-03-28 18:07:00 UTC (rev 230035)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010, 2014-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2014-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -79,7 +79,7 @@
IPC::Connection::Identifier connectionIdentifier(socketPair.server);
IPC::Attachment connectionClientPort(socketPair.client);
#elif OS(DARWIN)
- mach_port_t listeningPort;
+ mach_port_t listeningPort = MACH_PORT_NULL;
if (mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &listeningPort) != KERN_SUCCESS)
CRASH();
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (230034 => 230035)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2018-03-28 17:53:21 UTC (rev 230034)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2018-03-28 18:07:00 UTC (rev 230035)
@@ -1,3 +1,66 @@
+2018-03-28 Brent Fulgham <[email protected]>
+
+ Avoid uninitialized mach ports
+ https://bugs.webkit.org/show_bug.cgi?id=184090
+ <rdar://problem/37261129>
+
+ Reviewed by Chris Dumez.
+
+ It is possible for mach_port_allocate to return an error, but we rarely check its return value. The value
+ of the argument passed to mach_port_allocate is not guaranteed to be valid when it returns an error, so
+ there is a potential for us to try to use invalid ports.
+
+ We should always check return values, and ensure that the mach port variables we seek to initialize are
+ kept in a valid state.
+
+ Reviewed by Chris Dumez.
+
+ * Plugins/Hosted/NetscapePluginHostManager.h:
+ * Plugins/Hosted/NetscapePluginHostManager.mm:
+ (WebKit::NetscapePluginHostManager::hostForPlugin): Initialize port to a valid state, ASSERT if an invalid
+ port is passed to an API function.
+ (WebKit::NetscapePluginHostManager::spawnPluginHost): Ditto.
+ (WebKit::NetscapePluginHostManager::initializeVendorPort): Ditto.
+ * Plugins/Hosted/NetscapePluginHostProxy.h:
+ * Plugins/Hosted/NetscapePluginHostProxy.mm:
+ (WebKit::NetscapePluginHostProxy::NetscapePluginHostProxy): Ditto.
+ (WebKit::NetscapePluginHostProxy::~NetscapePluginHostProxy): Ditto.
+ (WebKit::NetscapePluginHostProxy::processRequests): Ditto.
+ (WKPCStatusText): Ditto.
+ (WKPCLoadURL): Ditto.
+ (WKPCCancelLoadURL): Ditto.
+ (WKPCInvalidateRect): Ditto.
+ (WKPCGetScriptableNPObjectReply): Ditto.
+ (WKPCBooleanReply): Ditto.
+ (WKPCBooleanAndDataReply): Ditto.
+ (WKPCInstantiatePluginReply): Ditto.
+ (WKPCGetWindowNPObject): Ditto.
+ (WKPCGetPluginElementNPObject): Ditto.
+ (WKPCForgetBrowserObject): Ditto.
+ (WKPCEvaluate): Ditto.
+ (WKPCGetStringIdentifier): Ditto.
+ (WKPCGetIntIdentifier): Ditto.
+ (WKPCInvoke): Ditto.
+ (WKPCInvokeDefault): Ditto.
+ (WKPCConstruct): Ditto.
+ (WKPCGetProperty): Ditto.
+ (WKPCSetProperty): Ditto.
+ (WKPCRemoveProperty): Ditto.
+ (WKPCHasProperty): Ditto.
+ (WKPCHasMethod): Ditto.
+ (WKPCIdentifierInfo): Ditto.
+ (WKPCEnumerate): Ditto.
+ (WKPCSetMenuBarVisible): Ditto.
+ (WKPCSetFullscreenWindowIsShowing): Ditto.
+ (WKPCSetModal): Ditto.
+ (WKPCGetCookies): Ditto.
+ (WKPCGetProxy): Ditto.
+ (WKPCSetCookies): Ditto.
+ (WKPCGetAuthenticationInfo): Ditto.
+ (WKPCConvertPoint): Ditto.
+ (WKPCLayerHostingModeChanged): Ditto.
+ (WKPCSetException): Ditto.
+
2018-03-26 Tim Horton <[email protected]>
Adopt WK_ALTERNATE_FRAMEWORKS_DIR in WebKit
Modified: trunk/Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginHostManager.h (230034 => 230035)
--- trunk/Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginHostManager.h 2018-03-28 17:53:21 UTC (rev 230034)
+++ trunk/Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginHostManager.h 2018-03-28 18:07:00 UTC (rev 230035)
@@ -63,7 +63,7 @@
bool initializeVendorPort();
- mach_port_t m_pluginVendorPort;
+ mach_port_t m_pluginVendorPort { MACH_PORT_NULL };
// FIXME: This should really be a HashMap of RetainPtrs, but that doesn't work right now.
typedef HashMap<String, NetscapePluginHostProxy*> PluginHostMap;
Modified: trunk/Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginHostManager.mm (230034 => 230035)
--- trunk/Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginHostManager.mm 2018-03-28 17:53:21 UTC (rev 230034)
+++ trunk/Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginHostManager.mm 2018-03-28 18:07:00 UTC (rev 230035)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2017 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008-2018 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -75,18 +75,18 @@
if (!result.isNewEntry)
return result.iterator->value;
- mach_port_t clientPort;
+ mach_port_t clientPort = MACH_PORT_NULL;
if (mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &clientPort) != KERN_SUCCESS) {
m_pluginHosts.remove(result.iterator);
- return 0;
+ return nullptr;
}
- mach_port_t pluginHostPort;
+ mach_port_t pluginHostPort = MACH_PORT_NULL;
ProcessSerialNumber pluginHostPSN;
if (!spawnPluginHost(pluginPath, pluginArchitecture, clientPort, pluginHostPort, pluginHostPSN)) {
mach_port_destroy(mach_task_self(), clientPort);
m_pluginHosts.remove(result.iterator);
- return 0;
+ return nullptr;
}
// Since Flash NPObjects add methods dynamically, we don't want to cache when a property/method doesn't exist
@@ -192,6 +192,7 @@
GetCurrentProcess(&psn);
#pragma clang diagnostic pop
+ ASSERT(MACH_PORT_VALID(clientPort));
kr = _WKPHCheckInWithPluginHost(pluginHostPort, static_cast<uint8_t*>(const_cast<void*>([data bytes])), [data length], clientPort, psn.highLongOfPSN, psn.lowLongOfPSN, renderServerPort,
&pluginHostPSN.highLongOfPSN, &pluginHostPSN.lowLongOfPSN);
@@ -210,7 +211,7 @@
ASSERT(m_pluginVendorPort == MACH_PORT_NULL);
// Get the plug-in agent port.
- mach_port_t pluginAgentPort;
+ mach_port_t pluginAgentPort = MACH_PORT_NULL;
if (bootstrap_look_up(bootstrap_port, "com.apple.WebKit.PluginAgent", &pluginAgentPort) != KERN_SUCCESS) {
LOG_ERROR("Failed to look up the plug-in agent port");
return false;
Modified: trunk/Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginHostProxy.h (230034 => 230035)
--- trunk/Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginHostProxy.h 2018-03-28 17:53:21 UTC (rev 230034)
+++ trunk/Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginHostProxy.h 2018-03-28 18:07:00 UTC (rev 230035)
@@ -23,11 +23,10 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#pragma once
+
#if USE(PLUGIN_HOST_PROCESS)
-#ifndef NetscapePluginHostProxy_h
-#define NetscapePluginHostProxy_h
-
#include <dispatch/dispatch.h>
#include <wtf/HashMap.h>
#include <wtf/RetainPtr.h>
@@ -85,11 +84,11 @@
typedef HashMap<uint32_t, RefPtr<NetscapePluginInstanceProxy>> PluginInstanceMap;
PluginInstanceMap m_instances;
- mach_port_t m_clientPort;
- mach_port_t m_portSet;
+ mach_port_t m_clientPort { MACH_PORT_NULL };
+ mach_port_t m_portSet { MACH_PORT_NULL };
RetainPtr<CFRunLoopSourceRef> m_clientPortSource;
- mach_port_t m_pluginHostPort;
+ mach_port_t m_pluginHostPort { MACH_PORT_NULL };
RetainPtr<CFMachPortRef> m_deadNameNotificationPort;
RetainPtr<id> m_activationObserver;
@@ -106,5 +105,4 @@
} // namespace WebKit
-#endif // NetscapePluginHostProxy_h
#endif // USE(PLUGIN_HOST_PROCESS)
Modified: trunk/Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginHostProxy.mm (230034 => 230035)
--- trunk/Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginHostProxy.mm 2018-03-28 17:53:21 UTC (rev 230034)
+++ trunk/Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginHostProxy.mm 2018-03-28 18:07:00 UTC (rev 230035)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2017 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008-2018 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -94,7 +94,6 @@
NetscapePluginHostProxy::NetscapePluginHostProxy(mach_port_t clientPort, mach_port_t pluginHostPort, const ProcessSerialNumber& pluginHostPSN, bool shouldCacheMissingPropertiesAndMethods)
: m_clientPort(clientPort)
- , m_portSet(MACH_PORT_NULL)
, m_pluginHostPort(pluginHostPort)
, m_isModal(false)
, m_menuBarIsVisible(true)
@@ -102,6 +101,9 @@
, m_pluginHostPSN(pluginHostPSN)
, m_shouldCacheMissingPropertiesAndMethods(shouldCacheMissingPropertiesAndMethods)
{
+ ASSERT(MACH_PORT_VALID(m_clientPort));
+ ASSERT(MACH_PORT_VALID(m_pluginHostPort));
+
pluginProxyMap().add(m_clientPort, this);
// FIXME: We should use libdispatch for this.
@@ -108,7 +110,7 @@
CFMachPortContext context = { 0, this, 0, 0, 0 };
m_deadNameNotificationPort = adoptCF(CFMachPortCreate(0, deadNameNotificationCallback, &context, 0));
- mach_port_t previous;
+ mach_port_t previous = MACH_PORT_NULL;
mach_port_request_notification(mach_task_self(), pluginHostPort, MACH_NOTIFY_DEAD_NAME, 0,
CFMachPortGetPort(m_deadNameNotificationPort.get()), MACH_MSG_TYPE_MAKE_SEND_ONCE, &previous);
ASSERT(previous == MACH_PORT_NULL);
@@ -131,6 +133,7 @@
mach_port_extract_member(mach_task_self(), m_clientPort, m_portSet);
mach_port_extract_member(mach_task_self(), CFMachPortGetPort(m_deadNameNotificationPort.get()), m_portSet);
mach_port_destroy(mach_task_self(), m_portSet);
+ m_portSet = MACH_PORT_NULL;
}
ASSERT(m_clientPortSource);
@@ -278,8 +281,12 @@
{
s_processingRequests++;
- if (!m_portSet) {
- mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_PORT_SET, &m_portSet);
+ if (!m_portSet) {
+ auto kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_PORT_SET, &m_portSet);
+ if (kr != KERN_SUCCESS) {
+ LOG_ERROR("Could not allocate mach port, error %x", kr);
+ CRASH();
+ }
mach_port_insert_member(mach_task_self(), m_clientPort, m_portSet);
mach_port_insert_member(mach_task_self(), CFMachPortGetPort(m_deadNameNotificationPort.get()), m_portSet);
}
@@ -387,6 +394,8 @@
// MiG callbacks
kern_return_t WKPCStatusText(mach_port_t clientPort, uint32_t pluginID, data_t text, mach_msg_type_number_t textCnt)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
DataDeallocator deallocator(text, textCnt);
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
@@ -405,6 +414,8 @@
data_t postData, mach_msg_type_number_t postDataLength, uint32_t flags,
uint16_t* outResult, uint32_t* outStreamID)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
DataDeallocator urlDeallocator(url, urlLength);
DataDeallocator targetDeallocator(target, targetLength);
DataDeallocator postDataDeallocator(postData, postDataLength);
@@ -427,6 +438,8 @@
kern_return_t WKPCCancelLoadURL(mach_port_t clientPort, uint32_t pluginID, uint32_t streamID, int16_t reason)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
if (!hostProxy)
return KERN_FAILURE;
@@ -443,6 +456,8 @@
kern_return_t WKPCInvalidateRect(mach_port_t clientPort, uint32_t pluginID, double x, double y, double width, double height)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
if (!hostProxy)
return KERN_SUCCESS;
@@ -466,6 +481,8 @@
kern_return_t WKPCGetScriptableNPObjectReply(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
if (!hostProxy)
return KERN_FAILURE;
@@ -480,6 +497,8 @@
kern_return_t WKPCBooleanReply(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, boolean_t result)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
if (!hostProxy)
return KERN_FAILURE;
@@ -494,6 +513,8 @@
kern_return_t WKPCBooleanAndDataReply(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, boolean_t returnValue, data_t resultData, mach_msg_type_number_t resultLength)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
DataDeallocator deallocator(resultData, resultLength);
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
@@ -512,6 +533,8 @@
kern_return_t WKPCInstantiatePluginReply(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, kern_return_t result, uint32_t renderContextID, uint32_t rendererType)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
if (!hostProxy)
return KERN_FAILURE;
@@ -526,6 +549,8 @@
kern_return_t WKPCGetWindowNPObject(mach_port_t clientPort, uint32_t pluginID, uint32_t* outObjectID)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
if (!hostProxy)
return KERN_FAILURE;
@@ -544,6 +569,8 @@
kern_return_t WKPCGetPluginElementNPObject(mach_port_t clientPort, uint32_t pluginID, uint32_t* outObjectID)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
if (!hostProxy)
return KERN_FAILURE;
@@ -562,6 +589,8 @@
kern_return_t WKPCForgetBrowserObject(mach_port_t clientPort, uint32_t pluginID, uint32_t objectID)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
if (!hostProxy)
return KERN_FAILURE;
@@ -575,6 +604,8 @@
kern_return_t WKPCEvaluate(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID, data_t scriptData, mach_msg_type_number_t scriptLength, boolean_t allowPopups)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
DataDeallocator deallocator(scriptData, scriptLength);
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
@@ -606,6 +637,8 @@
kern_return_t WKPCGetStringIdentifier(mach_port_t clientPort, data_t name, mach_msg_type_number_t nameCnt, uint64_t* identifier)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
DataDeallocator deallocator(name, nameCnt);
COMPILE_ASSERT(sizeof(*identifier) == sizeof(IdentifierRep*), identifier_sizes);
@@ -616,6 +649,8 @@
kern_return_t WKPCGetIntIdentifier(mach_port_t clientPort, int32_t value, uint64_t* identifier)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
COMPILE_ASSERT(sizeof(*identifier) == sizeof(NPIdentifier), identifier_sizes);
*identifier = reinterpret_cast<uint64_t>(IdentifierRep::get(value));
@@ -634,6 +669,8 @@
kern_return_t WKPCInvoke(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID, uint64_t serverIdentifier,
data_t argumentsData, mach_msg_type_number_t argumentsLength)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
DataDeallocator deallocator(argumentsData, argumentsLength);
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
@@ -670,6 +707,8 @@
kern_return_t WKPCInvokeDefault(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID,
data_t argumentsData, mach_msg_type_number_t argumentsLength)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
DataDeallocator deallocator(argumentsData, argumentsLength);
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
@@ -701,6 +740,8 @@
data_t argumentsData, mach_msg_type_number_t argumentsLength,
boolean_t* returnValue, data_t* resultData, mach_msg_type_number_t* resultLength)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
DataDeallocator deallocator(argumentsData, argumentsLength);
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
@@ -720,6 +761,8 @@
kern_return_t WKPCGetProperty(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID, uint64_t serverIdentifier)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
if (!hostProxy)
return KERN_FAILURE;
@@ -757,6 +800,8 @@
kern_return_t WKPCSetProperty(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID, uint64_t serverIdentifier, data_t valueData, mach_msg_type_number_t valueLength)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
DataDeallocator deallocator(valueData, valueLength);
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
@@ -791,6 +836,8 @@
kern_return_t WKPCRemoveProperty(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID, uint64_t serverIdentifier)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
if (!hostProxy)
return KERN_FAILURE;
@@ -823,6 +870,8 @@
kern_return_t WKPCHasProperty(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID, uint64_t serverIdentifier)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
if (!hostProxy)
return KERN_FAILURE;
@@ -855,6 +904,8 @@
kern_return_t WKPCHasMethod(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID, uint64_t serverIdentifier)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
if (!hostProxy)
return KERN_FAILURE;
@@ -883,6 +934,8 @@
kern_return_t WKPCIdentifierInfo(mach_port_t clientPort, uint64_t serverIdentifier, data_t* infoData, mach_msg_type_number_t* infoLength)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
IdentifierRep* identifier = reinterpret_cast<IdentifierRep*>(serverIdentifier);
if (!IdentifierRep::isValid(identifier))
return KERN_FAILURE;
@@ -907,6 +960,8 @@
kern_return_t WKPCEnumerate(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
if (!hostProxy)
return KERN_FAILURE;
@@ -933,6 +988,8 @@
kern_return_t WKPCSetMenuBarVisible(mach_port_t clientPort, boolean_t menuBarVisible)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
if (!hostProxy)
return KERN_FAILURE;
@@ -944,6 +1001,8 @@
kern_return_t WKPCSetFullscreenWindowIsShowing(mach_port_t clientPort, boolean_t fullscreenWindowIsShowing)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
if (!hostProxy)
return KERN_FAILURE;
@@ -955,6 +1014,8 @@
kern_return_t WKPCSetModal(mach_port_t clientPort, boolean_t modal)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
if (!hostProxy)
return KERN_FAILURE;
@@ -977,7 +1038,9 @@
data_t urlData, mach_msg_type_number_t urlLength,
boolean_t* returnValue, data_t* cookiesData, mach_msg_type_number_t* cookiesLength)
{
- *cookiesData = 0;
+ ASSERT(MACH_PORT_VALID(clientPort));
+
+ *cookiesData = nullptr;
*cookiesLength = 0;
DataDeallocator deallocator(urlData, urlLength);
@@ -999,7 +1062,9 @@
data_t urlData, mach_msg_type_number_t urlLength,
boolean_t* returnValue, data_t* proxyData, mach_msg_type_number_t* proxyLength)
{
- *proxyData = 0;
+ ASSERT(MACH_PORT_VALID(clientPort));
+
+ *proxyData = nullptr;
*proxyLength = 0;
DataDeallocator deallocator(urlData, urlLength);
@@ -1022,6 +1087,8 @@
data_t cookiesData, mach_msg_type_number_t cookiesLength,
boolean_t* returnValue)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
DataDeallocator urlDeallocator(urlData, urlLength);
DataDeallocator cookiesDeallocator(cookiesData, cookiesLength);
@@ -1047,14 +1114,16 @@
data_t* usernameData, mach_msg_type_number_t *usernameLength,
data_t* passwordData, mach_msg_type_number_t *passwordLength)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
DataDeallocator protocolDeallocator(protocolData, protocolLength);
DataDeallocator hostDeallocator(hostData, hostLength);
DataDeallocator schemeDeallocator(schemeData, schemeLength);
DataDeallocator realmDeallocator(realmData, realmLength);
- *usernameData = 0;
+ *usernameData = nullptr;
*usernameLength = 0;
- *passwordData = 0;
+ *passwordData = nullptr;
*passwordLength = 0;
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
@@ -1074,6 +1143,8 @@
double sourceX, double sourceY, uint32_t sourceSpace,
uint32_t destSpace, boolean_t *returnValue, double *destX, double *destY)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
if (!hostProxy)
return KERN_FAILURE;
@@ -1089,6 +1160,8 @@
kern_return_t WKPCLayerHostingModeChanged(mach_port_t clientPort, uint32_t pluginID, boolean_t hostsLayersInWindowServer, uint32_t renderContextID)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
if (!hostProxy)
return KERN_FAILURE;
@@ -1104,6 +1177,8 @@
kern_return_t WKPCSetException(mach_port_t clientPort, data_t message, mach_msg_type_number_t messageCnt)
{
+ ASSERT(MACH_PORT_VALID(clientPort));
+
DataDeallocator deallocator(message, messageCnt);
NetscapePluginInstanceProxy::setGlobalException(String::fromUTF8WithLatin1Fallback(message, messageCnt));