Changeset 65703 in webkit


Ignore:
Timestamp:
Aug 19, 2010 2:22:13 PM (14 years ago)
Author:
Adam Roben
Message:

Call NP_GetEntryPoints before NP_Initialize on Windows

Doing otherwise will cause Flash and QuickTime to crash inside
NP_Initialize.

Fixes <http://webkit.org/b/44270> <rdar://problem/8330393> Crash in
NP_Initialize when loading QuickTime when running
plugins/embed-attributes-setting.html in WebKit2 on Windows

Reviewed by Sam Weinig.

WebKit2:

  • WebProcess/Plugins/Netscape/NetscapePluginModule.cpp:

(WebKit::NetscapePluginModule::tryLoad): On Windows, first call
NP_GetEntryPoints, then NP_Initialize. Do the reverse on Mac to
prevent Silverlight (e.g.) from crashing (see r38858).

WebKitTools:

Test that NP_Initialize and NP_GetEntryPoints are called in the
correct order

The order differs between Mac and Windows (see r38858).

  • DumpRenderTree/TestNetscapePlugIn/main.cpp: Added a CRASH macro and

a boolean to record whether NP_GetEntryPoints has been called.
(NP_Initialize): Crash on Windows if NP_GetEntryPoints hasn't been
called yet. This matches Flash and QuickTime's behavior. Crash on Mac
if NP_GetEntryPoints has been called already. This matches
Silverlight's behavior.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r65702 r65703  
     12010-08-19  Adam Roben  <aroben@apple.com>
     2
     3        Call NP_GetEntryPoints before NP_Initialize on Windows
     4
     5        Doing otherwise will cause Flash and QuickTime to crash inside
     6        NP_Initialize.
     7
     8        Fixes <http://webkit.org/b/44270> <rdar://problem/8330393> Crash in
     9        NP_Initialize when loading QuickTime when running
     10        plugins/embed-attributes-setting.html in WebKit2 on Windows
     11
     12        Reviewed by Sam Weinig.
     13
     14        * WebProcess/Plugins/Netscape/NetscapePluginModule.cpp:
     15        (WebKit::NetscapePluginModule::tryLoad): On Windows, first call
     16        NP_GetEntryPoints, then NP_Initialize. Do the reverse on Mac to
     17        prevent Silverlight (e.g.) from crashing (see r38858).
     18
    1192010-08-19  Adam Roben  <aroben@apple.com>
    220
  • trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginModule.cpp

    r65465 r65703  
    130130        return false;
    131131
    132     if (initializeFuncPtr(netscapeBrowserFuncs()) != NPERR_NO_ERROR)
    133         return false;
    134 
    135132    m_pluginFuncs.size = sizeof(NPPluginFuncs);
    136133    m_pluginFuncs.version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
    137     if (getEntryPointsFuncPtr(&m_pluginFuncs) != NPERR_NO_ERROR)
     134
     135    // On Mac, NP_Initialize must be called first, then NP_GetEntryPoints. On Windows, the order is
     136    // reversed. Failing to follow this order results in crashes (e.g., in Silverlight on Mac and
     137    // in Flash and QuickTime on Windows).
     138#if PLATFORM(MAC)
     139    if (initializeFuncPtr(netscapeBrowserFuncs()) != NPERR_NO_ERROR || getEntryPointsFuncPtr(&m_pluginFuncs) != NPERR_NO_ERROR)
    138140        return false;
     141#elif PLATFORM(WIN)
     142    if (getEntryPointsFuncPtr(&m_pluginFuncs) != NPERR_NO_ERROR || initializeFuncPtr(netscapeBrowserFuncs()) != NPERR_NO_ERROR)
     143        return false;
     144#endif
    139145
    140146    return true;
  • trunk/WebKitTools/ChangeLog

    r65701 r65703  
     12010-08-19  Adam Roben  <aroben@apple.com>
     2
     3        Test that NP_Initialize and NP_GetEntryPoints are called in the
     4        correct order
     5
     6        The order differs between Mac and Windows (see r38858).
     7
     8        Fixes <http://webkit.org/b/44270> <rdar://problem/8330393> Crash in
     9        NP_Initialize when loading QuickTime when running
     10        plugins/embed-attributes-setting.html in WebKit2 on Windows
     11
     12        Reviewed by Sam Weinig.
     13
     14        * DumpRenderTree/TestNetscapePlugIn/main.cpp: Added a CRASH macro and
     15        a boolean to record whether NP_GetEntryPoints has been called.
     16        (NP_Initialize): Crash on Windows if NP_GetEntryPoints hasn't been
     17        called yet. This matches Flash and QuickTime's behavior. Crash on Mac
     18        if NP_GetEntryPoints has been called already. This matches
     19        Silverlight's behavior.
     20
    1212010-08-19  Adam Roben  <aroben@apple.com>
    222
  • trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn/main.cpp

    r64359 r65703  
    3232using namespace std;
    3333
     34#define CRASH() do { \
     35    *(int *)(uintptr_t)0xbbadbeef = 0; \
     36    ((void(*)())0)(); /* More reliable, but doesn't say BBADBEEF */ \
     37} while(false)
     38
     39static bool getEntryPointsWasCalled;
     40
    3441#if XP_WIN
    3542#define STDCALL __stdcall
     
    4855NPError STDCALL NP_Initialize(NPNetscapeFuncs *browserFuncs)
    4956{
     57#if XP_WIN
     58    // Simulate Flash and QuickTime's behavior of crashing when NP_Initialize is called before NP_GetEntryPoints.
     59    if (!getEntryPointsWasCalled)
     60        CRASH();
     61#elif XP_MACOSX
     62    // Simulate Silverlight's behavior of crashing when NP_GetEntryPoints is called before NP_Initialize.
     63    if (getEntryPointsWasCalled)
     64        CRASH();
     65#endif
     66
    5067    browser = browserFuncs;
    5168    return NPERR_NO_ERROR;
     
    5572NPError STDCALL NP_GetEntryPoints(NPPluginFuncs *pluginFuncs)
    5673{
     74    getEntryPointsWasCalled = true;
     75
    5776    pluginFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
    5877    pluginFuncs->size = sizeof(pluginFuncs);
Note: See TracChangeset for help on using the changeset viewer.