<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>19309</bug_id>
          
          <creation_ts>2008-05-29 09:09:05 -0700</creation_ts>
          <short_desc>uninitialised variable in PluginView</short_desc>
          <delta_ts>2008-06-08 11:17:35 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Plug-ins</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>OS X 10.5</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Christian Persch (GNOME) (away; not reading bugmail)">chpe</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>alp</cc>
    
    <cc>darin</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>81846</commentid>
    <comment_count>0</comment_count>
    <who name="Christian Persch (GNOME) (away; not reading bugmail)">chpe</who>
    <bug_when>2008-05-29 09:09:05 -0700</bug_when>
    <thetext>PluginView&apos;s NPP instance&apos;s pdata member is uninitialised. I was getting crashes in the totem plugins because of this; attached patch inits the var to 0. (This might have been a problem in the plugin itself, but I think it&apos;s better to be resilient against buggy plugins than just crash.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81847</commentid>
    <comment_count>1</comment_count>
      <attachid>21410</attachid>
    <who name="Christian Persch (GNOME) (away; not reading bugmail)">chpe</who>
    <bug_when>2008-05-29 09:10:50 -0700</bug_when>
    <thetext>Created attachment 21410
patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81854</commentid>
    <comment_count>2</comment_count>
      <attachid>21410</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2008-05-29 09:50:14 -0700</bug_when>
    <thetext>Comment on attachment 21410
patch

Isn&apos;t it the plug-in&apos;s responsibility to initialize pdata if it wants to use it?

I guess there&apos;s no harm in this in either case, so r=me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81856</commentid>
    <comment_count>3</comment_count>
    <who name="Alp Toker">alp</who>
    <bug_when>2008-05-29 10:01:23 -0700</bug_when>
    <thetext>The Moonlight plugin team also noticed they were relying on structures being zeroed when initialized, since this is Mozilla&apos;s behavour (at least on Linux/X11, I understand NPN_MemAlloc zeros as well as allocating while ours doesn&apos;t zero). They fixed the assumptions in their code, but I wonder if we should just go ahead and zero all newly-allocated data and structures passed to plugins as a rule rather than patching up issues individually as we discover them.

If plugins in the wild are assuming the allocated data is zeroed and transmitting uninitialised buffers over the network this could lead to security issues even in plugins that seem to work fine.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81860</commentid>
    <comment_count>4</comment_count>
    <who name="Alp Toker">alp</who>
    <bug_when>2008-05-29 10:31:38 -0700</bug_when>
    <thetext>CC&apos;ing Darin. We should probably skip this patch and match Mozilla&apos;s behaviour as I described since plugins are expecting zeroed input (even though the NPAPI docs warn plugin authors not to rely on this).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81862</commentid>
    <comment_count>5</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2008-05-29 10:39:29 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; The Moonlight plugin team also noticed they were relying on structures being
&gt; zeroed when initialized, since this is Mozilla&apos;s behavour (at least on
&gt; Linux/X11, I understand NPN_MemAlloc zeros as well as allocating while ours
&gt; doesn&apos;t zero). They fixed the assumptions in their code, but I wonder if we
&gt; should just go ahead and zero all newly-allocated data and structures passed to
&gt; plugins as a rule rather than patching up issues individually as we discover
&gt; them.

The NPN_MemAlloc change sounds OK. Any other specific cases?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81870</commentid>
    <comment_count>6</comment_count>
    <who name="Alp Toker">alp</who>
    <bug_when>2008-05-29 11:08:08 -0700</bug_when>
    <thetext>(In reply to comment #5)
&gt; 
&gt; The NPN_MemAlloc change sounds OK. Any other specific cases?
&gt; 

The WebKit NPP, NPWindow, NPStream we pass to plugins are allocated as part of the C++ class, and the default memory allocator used for objects doesn&apos;t zero. There are some attempts to zero the fields, but if you take a look at PluginStream.cpp, the &apos;headers&apos; field remains uninitialized until PluginStream::startStream(), by which time a plugin may already have tried to access it.

Perhaps it&apos;d be more effective to allocate and initialize these structures explicitly rather than pointing the plugin to an offset in the C++ class?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81879</commentid>
    <comment_count>7</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2008-05-29 12:07:33 -0700</bug_when>
    <thetext>(In reply to comment #6)
&gt; Perhaps it&apos;d be more effective to allocate and initialize these structures
&gt; explicitly rather than pointing the plugin to an offset in the C++ class?

That sounds like overkill. It&apos;s trivial to initialize to 0:

    memset(&amp;x, 0, sizeof(x));

So if we want initialization, then lets add it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82620</commentid>
    <comment_count>8</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2008-06-08 11:17:35 -0700</bug_when>
    <thetext>Committed revision 34443.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>21410</attachid>
            <date>2008-05-29 09:10:50 -0700</date>
            <delta_ts>2008-05-29 09:50:14 -0700</delta_ts>
            <desc>patch</desc>
            <filename>P</filename>
            <type>text/plain</type>
            <size>882</size>
            <attacher name="Christian Persch (GNOME) (away; not reading bugmail)">chpe</attacher>
            
              <data encoding="base64">ZGlmZiA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W5j
ZS0+bmRhdGEgPSB0aGlzOworICAgIG1faW5zdGFuY2UtPnBkYXRhID0gMDsKIAogICAgIG1fbWlt
ZVR5cGUgPSBtaW1lVHlwZS51dGY4KCk7CiAK
</data>
<flag name="review"
          id="9365"
          type_id="1"
          status="+"
          setter="darin"
    />
          </attachment>
      

    </bug>

</bugzilla>