[vlc-devel] [PATCH 1/4] Fix check for plugin table size

Cheng Sun cheng.sun at ymail.com
Mon Dec 31 00:12:50 CET 2012


On 30/12/12 22:59, Rafaël Carré wrote:
> Le 30/12/2012 21:51, Cheng Sun a écrit :
>> ---
>>  npapi/support/npunix.cpp | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/npapi/support/npunix.cpp b/npapi/support/npunix.cpp
>> index 0f4baaf..1f3f778 100644
>> --- a/npapi/support/npunix.cpp
>> +++ b/npapi/support/npunix.cpp
>> @@ -847,7 +847,7 @@ NP_Initialize(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs)
>>              err = NPERR_INCOMPATIBLE_VERSION_ERROR;
>>          if (nsTable->size < ((char *)&nsTable->posturlnotify - (char *)nsTable))
>>              err = NPERR_INVALID_FUNCTABLE_ERROR;
>> -        if (pluginFuncs->size < sizeof(NPPluginFuncs))
>> +        if (pluginFuncs->size < (char *)&pluginFuncs->setvalue - (char *)pluginFuncs)
>>              err = NPERR_INVALID_FUNCTABLE_ERROR;
>>      }
> 
> What does it fix exactly?

The NPAPI library version that we've been compiled with might be *more
recent* than the NPAPI header version of the browser. Which means that
the pluginFuncs table that we have has more entries in it than the
browser is expecting. However, NPAPI was designed with
backwards-compatibility in mind, and when the plugin table is revised by
Mozilla, new entries are added to the end of the table.

Before we were asserting that the plugin table that the browser gives us
to fill in is big enough for the entire table that we've been compiled
with, but now we check whether the table is just big enough for the
entries that we actually use.

HTH.

- Cheng



More information about the vlc-devel mailing list