218c6c9d0d
git-svn-id: http://svn.sabayonlinux.org/overlay@2037 d7aec97c-591d-0410-af39-a8856400b30a
415 lines
11 KiB
Diff
415 lines
11 KiB
Diff
diff -up nspluginwrapper-0.9.91.5/src/npw-viewer.c.old nspluginwrapper-0.9.91.5/src/npw-viewer.c
|
|
--- nspluginwrapper-0.9.91.5/src/npw-viewer.c.old 2007-10-15 10:56:37.000000000 +0200
|
|
+++ nspluginwrapper-0.9.91.5/src/npw-viewer.c 2007-10-15 11:18:57.000000000 +0200
|
|
@@ -64,6 +64,20 @@
|
|
// RPC global connections
|
|
rpc_connection_t *g_rpc_connection attribute_hidden = NULL;
|
|
|
|
+// Viewer orignal pid - check against incorrect plugins
|
|
+pid_t viewer_pid = 0;
|
|
+
|
|
+// Pid support routines
|
|
+void pid_set(void)
|
|
+{
|
|
+ viewer_pid = getpid();
|
|
+}
|
|
+
|
|
+int pid_check(void)
|
|
+{
|
|
+ return(viewer_pid == getpid());
|
|
+}
|
|
+
|
|
// Instance state information about the plugin
|
|
typedef struct _PluginInstance {
|
|
NPP instance;
|
|
@@ -542,6 +556,9 @@ static void
|
|
g_NPN_ForceRedraw(NPP instance)
|
|
{
|
|
D(bug("NPN_ForceRedraw instance=%p\n", instance));
|
|
+
|
|
+ if(!pid_check())
|
|
+ return NPERR_INVALID_INSTANCE_ERROR;
|
|
|
|
UNIMPLEMENTED();
|
|
}
|
|
@@ -576,9 +593,11 @@ invoke_NPN_GetURL(NPP instance, const ch
|
|
static NPError
|
|
g_NPN_GetURL(NPP instance, const char *url, const char *target)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return NPERR_INVALID_INSTANCE_ERROR;
|
|
if (instance == NULL)
|
|
return NPERR_INVALID_INSTANCE_ERROR;
|
|
-
|
|
+
|
|
D(bug("NPN_GetURL instance=%p\n", instance));
|
|
NPError ret = invoke_NPN_GetURL(instance, url, target);
|
|
D(bug(" return: %d [%s]\n", ret, string_of_NPError(ret)));
|
|
@@ -616,6 +635,9 @@ invoke_NPN_GetURLNotify(NPP instance, co
|
|
static NPError
|
|
g_NPN_GetURLNotify(NPP instance, const char *url, const char *target, void *notifyData)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return NPERR_INVALID_INSTANCE_ERROR;
|
|
+
|
|
if (instance == NULL)
|
|
return NPERR_INVALID_INSTANCE_ERROR;
|
|
|
|
@@ -682,8 +704,11 @@ invoke_NPN_GetValue(NPP instance, NPNVar
|
|
|
|
static NPError
|
|
g_NPN_GetValue(NPP instance, NPNVariable variable, void *value)
|
|
-{
|
|
+{
|
|
D(bug("NPN_GetValue instance=%p, variable=%d [%08x]\n", instance, variable & 0xffff, variable));
|
|
+
|
|
+ if(!pid_check())
|
|
+ return NPERR_INVALID_INSTANCE_ERROR;
|
|
|
|
switch (variable) {
|
|
case NPNVxDisplay:
|
|
@@ -737,6 +762,9 @@ static void
|
|
g_NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
|
|
{
|
|
D(bug("NPN_InvalidateRect instance=%p\n", instance));
|
|
+
|
|
+ if(!pid_check())
|
|
+ return NPERR_INVALID_INSTANCE_ERROR;
|
|
|
|
UNIMPLEMENTED();
|
|
}
|
|
@@ -746,6 +774,9 @@ static void
|
|
g_NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
|
|
{
|
|
D(bug("NPN_InvalidateRegion instance=%p\n", instance));
|
|
+
|
|
+ if(!pid_check())
|
|
+ return NPERR_INVALID_INSTANCE_ERROR;
|
|
|
|
UNIMPLEMENTED();
|
|
}
|
|
@@ -809,6 +840,8 @@ invoke_NPN_PostURL(NPP instance, const c
|
|
static NPError
|
|
g_NPN_PostURL(NPP instance, const char *url, const char *target, uint32 len, const char *buf, NPBool file)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return NPERR_INVALID_INSTANCE_ERROR;
|
|
if (instance == NULL)
|
|
return NPERR_INVALID_INSTANCE_ERROR;
|
|
|
|
@@ -851,6 +884,9 @@ invoke_NPN_PostURLNotify(NPP instance, c
|
|
static NPError
|
|
g_NPN_PostURLNotify(NPP instance, const char *url, const char *target, uint32 len, const char *buf, NPBool file, void *notifyData)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return NPERR_INVALID_INSTANCE_ERROR;
|
|
+
|
|
if (instance == NULL)
|
|
return NPERR_INVALID_INSTANCE_ERROR;
|
|
|
|
@@ -865,6 +901,9 @@ static void
|
|
g_NPN_ReloadPlugins(NPBool reloadPages)
|
|
{
|
|
D(bug("NPN_ReloadPlugins reloadPages=%d\n", reloadPages));
|
|
+
|
|
+ if(!pid_check())
|
|
+ return;
|
|
|
|
UNIMPLEMENTED();
|
|
}
|
|
@@ -874,6 +913,9 @@ static JRIEnv *
|
|
g_NPN_GetJavaEnv(void)
|
|
{
|
|
D(bug("NPN_GetJavaEnv\n"));
|
|
+
|
|
+ if(!pid_check())
|
|
+ return NULL;
|
|
|
|
return NULL;
|
|
}
|
|
@@ -883,6 +925,9 @@ static jref
|
|
g_NPN_GetJavaPeer(NPP instance)
|
|
{
|
|
D(bug("NPN_GetJavaPeer instance=%p\n", instance));
|
|
+
|
|
+ if(!pid_check())
|
|
+ return NULL;
|
|
|
|
return NULL;
|
|
}
|
|
@@ -916,6 +961,8 @@ invoke_NPN_RequestRead(NPStream *stream,
|
|
static NPError
|
|
g_NPN_RequestRead(NPStream *stream, NPByteRange *rangeList)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return NPERR_INVALID_INSTANCE_ERROR;
|
|
if (stream == NULL || stream->ndata == NULL || rangeList == NULL)
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
@@ -930,6 +977,9 @@ static NPError
|
|
g_NPN_SetValue(NPP instance, NPPVariable variable, void *value)
|
|
{
|
|
D(bug("NPN_SetValue instance=%p\n", instance));
|
|
+
|
|
+ if(!pid_check())
|
|
+ return NPERR_INVALID_INSTANCE_ERROR;
|
|
|
|
UNIMPLEMENTED();
|
|
|
|
@@ -962,6 +1012,9 @@ invoke_NPN_Status(NPP instance, const ch
|
|
static void
|
|
g_NPN_Status(NPP instance, const char *message)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return NPERR_INVALID_INSTANCE_ERROR;
|
|
+
|
|
D(bug("NPN_Status instance=%p\n", instance));
|
|
invoke_NPN_Status(instance, message);
|
|
D(bug(" done\n"));
|
|
@@ -990,6 +1043,9 @@ invoke_NPN_UserAgent(void)
|
|
static const char *
|
|
g_NPN_UserAgent(NPP instance)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return NPERR_INVALID_INSTANCE_ERROR;
|
|
+
|
|
D(bug("NPN_UserAgent instance=%p\n", instance));
|
|
if (g_user_agent == NULL)
|
|
g_user_agent = invoke_NPN_UserAgent();
|
|
@@ -1072,6 +1128,8 @@ invoke_NPN_NewStream(NPP instance, NPMIM
|
|
static NPError
|
|
g_NPN_NewStream(NPP instance, NPMIMEType type, const char *target, NPStream **stream)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return NPERR_INVALID_INSTANCE_ERROR;
|
|
if (instance == NULL)
|
|
return NPERR_INVALID_INSTANCE_ERROR;
|
|
|
|
@@ -1117,6 +1175,9 @@ invoke_NPN_DestroyStream(NPP instance, N
|
|
static NPError
|
|
g_NPN_DestroyStream(NPP instance, NPStream *stream, NPError reason)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return NPERR_INVALID_INSTANCE_ERROR;
|
|
+
|
|
if (instance == NULL)
|
|
return NPERR_INVALID_INSTANCE_ERROR;
|
|
|
|
@@ -1174,6 +1235,9 @@ invoke_NPN_Write(NPP instance, NPStream
|
|
static int32
|
|
g_NPN_Write(NPP instance, NPStream *stream, int32 len, void *buf)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return -1;
|
|
+
|
|
if (instance == NULL)
|
|
return -1;
|
|
|
|
@@ -1210,6 +1274,8 @@ invoke_NPN_PushPopupsEnabledState(NPP in
|
|
static void
|
|
g_NPN_PushPopupsEnabledState(NPP instance, NPBool enabled)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return;
|
|
if (instance == NULL)
|
|
return;
|
|
|
|
@@ -1241,6 +1307,8 @@ invoke_NPN_PopPopupsEnabledState(NPP ins
|
|
static void
|
|
g_NPN_PopPopupsEnabledState(NPP instance)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return;
|
|
if (instance == NULL)
|
|
return;
|
|
|
|
@@ -1284,6 +1352,9 @@ invoke_NPN_CreateObject(NPP instance)
|
|
static NPObject *
|
|
g_NPN_CreateObject(NPP instance, NPClass *class)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return NULL;
|
|
+
|
|
if (instance == NULL)
|
|
return NULL;
|
|
|
|
@@ -1324,6 +1395,9 @@ invoke_NPN_RetainObject(NPObject *npobj)
|
|
static NPObject *
|
|
g_NPN_RetainObject(NPObject *npobj)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return NULL;
|
|
+
|
|
if (npobj == NULL)
|
|
return NULL;
|
|
|
|
@@ -1362,6 +1436,9 @@ invoke_NPN_ReleaseObject(NPObject *npobj
|
|
static void
|
|
g_NPN_ReleaseObject(NPObject *npobj)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return;
|
|
+
|
|
if (npobj == NULL)
|
|
return;
|
|
|
|
@@ -1409,6 +1486,9 @@ static bool
|
|
g_NPN_Invoke(NPP instance, NPObject *npobj, NPIdentifier methodName,
|
|
const NPVariant *args, uint32_t argCount, NPVariant *result)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return false;
|
|
+
|
|
if (!instance || !npobj || !npobj->_class || !npobj->_class->invoke)
|
|
return false;
|
|
|
|
@@ -1453,6 +1533,9 @@ static bool
|
|
g_NPN_InvokeDefault(NPP instance, NPObject *npobj,
|
|
const NPVariant *args, uint32_t argCount, NPVariant *result)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return false;
|
|
+
|
|
if (!instance || !npobj || !npobj->_class || !npobj->_class->invokeDefault)
|
|
return false;
|
|
|
|
@@ -1495,6 +1578,9 @@ invoke_NPN_Evaluate(NPP instance, NPObje
|
|
static bool
|
|
g_NPN_Evaluate(NPP instance, NPObject *npobj, NPString *script, NPVariant *result)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return false;
|
|
+
|
|
if (!instance || !npobj)
|
|
return false;
|
|
|
|
@@ -1542,6 +1628,9 @@ static bool
|
|
g_NPN_GetProperty(NPP instance, NPObject *npobj, NPIdentifier propertyName,
|
|
NPVariant *result)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return false;
|
|
+
|
|
if (!instance || !npobj || !npobj->_class || !npobj->_class->getProperty)
|
|
return false;
|
|
|
|
@@ -1586,6 +1675,9 @@ static bool
|
|
g_NPN_SetProperty(NPP instance, NPObject *npobj, NPIdentifier propertyName,
|
|
const NPVariant *value)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return false;
|
|
+
|
|
if (!instance || !npobj || !npobj->_class || !npobj->_class->setProperty)
|
|
return false;
|
|
|
|
@@ -1627,6 +1719,9 @@ invoke_NPN_RemoveProperty(NPP instance,
|
|
static bool
|
|
g_NPN_RemoveProperty(NPP instance, NPObject *npobj, NPIdentifier propertyName)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return false;
|
|
+
|
|
if (!instance || !npobj || !npobj->_class || !npobj->_class->removeProperty)
|
|
return false;
|
|
|
|
@@ -1668,6 +1763,9 @@ invoke_NPN_HasProperty(NPP instance, NPO
|
|
static bool
|
|
g_NPN_HasProperty(NPP instance, NPObject *npobj, NPIdentifier propertyName)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return false;
|
|
+
|
|
if (!instance || !npobj || !npobj->_class || !npobj->_class->hasProperty)
|
|
return false;
|
|
|
|
@@ -1709,6 +1807,9 @@ invoke_NPN_HasMethod(NPP instance, NPObj
|
|
static bool
|
|
g_NPN_HasMethod(NPP instance, NPObject *npobj, NPIdentifier methodName)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return false;
|
|
+
|
|
if (!instance || !npobj || !npobj->_class || !npobj->_class->hasMethod)
|
|
return false;
|
|
|
|
@@ -1744,6 +1845,9 @@ invoke_NPN_SetException(NPObject *npobj,
|
|
static void
|
|
g_NPN_SetException(NPObject *npobj, const NPUTF8 *message)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return;
|
|
+
|
|
D(bug("NPN_SetException npobj=%p, message='%s'\n", npobj, message));
|
|
invoke_NPN_SetException(npobj, message);
|
|
D(bug(" done\n"));
|
|
@@ -1805,6 +1909,8 @@ invoke_NPN_GetStringIdentifier(const NPU
|
|
static NPIdentifier
|
|
g_NPN_GetStringIdentifier(const NPUTF8 *name)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return NULL;
|
|
if (name == NULL)
|
|
return NULL;
|
|
|
|
@@ -1854,6 +1960,9 @@ invoke_NPN_GetStringIdentifiers(const NP
|
|
static void
|
|
g_NPN_GetStringIdentifiers(const NPUTF8 **names, uint32_t nameCount, NPIdentifier *identifiers)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return;
|
|
+
|
|
if (names == NULL)
|
|
return;
|
|
|
|
@@ -1895,6 +2004,9 @@ invoke_NPN_GetIntIdentifier(int32_t inti
|
|
static NPIdentifier
|
|
g_NPN_GetIntIdentifier(int32_t intid)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return 0;
|
|
+
|
|
D(bug("NPN_GetIntIdentifier intid=%d\n", intid));
|
|
NPIdentifier ret = invoke_NPN_GetIntIdentifier(intid);
|
|
D(bug(" return: %p\n", ret));
|
|
@@ -1931,6 +2043,9 @@ invoke_NPN_IdentifierIsString(NPIdentifi
|
|
static bool
|
|
g_NPN_IdentifierIsString(NPIdentifier identifier)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return false;
|
|
+
|
|
D(bug("NPN_IdentifierIsString identifier=%p\n", identifier));
|
|
bool ret = invoke_NPN_IdentifierIsString(identifier);
|
|
D(bug(" return: %d\n", ret));
|
|
@@ -1967,6 +2082,9 @@ invoke_NPN_UTF8FromIdentifier(NPIdentifi
|
|
static NPUTF8 *
|
|
g_NPN_UTF8FromIdentifier(NPIdentifier identifier)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return NULL;
|
|
+
|
|
D(bug("NPN_UTF8FromIdentifier identifier=%p\n", identifier));
|
|
NPUTF8 *ret = invoke_NPN_UTF8FromIdentifier(identifier);
|
|
D(bug(" return: '%s'\n", ret));
|
|
@@ -2004,6 +2122,9 @@ invoke_NPN_IntFromIdentifier(NPIdentifie
|
|
static int32_t
|
|
g_NPN_IntFromIdentifier(NPIdentifier identifier)
|
|
{
|
|
+ if(!pid_check())
|
|
+ return 0;
|
|
+
|
|
D(bug("NPN_IntFromIdentifier identifier=%p\n", identifier));
|
|
int32_t ret = invoke_NPN_IntFromIdentifier(identifier);
|
|
D(bug(" return: %d\n", ret));
|
|
@@ -3008,6 +3129,9 @@ static int do_main(int argc, char **argv
|
|
}
|
|
D(bug(" Plugin connection: %s\n", connection_path));
|
|
|
|
+ pid_set();
|
|
+ D(bug(" Plugin viewer pid: %d\n", viewer_pid));
|
|
+
|
|
// Cleanup environment, the program may fork/exec a native shell
|
|
// script and having 32-bit libraries in LD_PRELOAD is not right,
|
|
// though not a fatal error
|