<?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>14853</bug_id>
          
          <creation_ts>2007-08-01 12:04:02 -0700</creation_ts>
          <short_desc>Incorrect implementation of ArrayImpl&apos;s equality operator</short_desc>
          <delta_ts>2007-08-29 10:45:11 -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>WebCore Misc.</component>
          <version>312.x</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>Minor</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>rick</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>3330</commentid>
    <comment_count>0</comment_count>
    <who name="">rick</who>
    <bug_when>2007-08-01 12:04:02 -0700</bug_when>
    <thetext>The ArrayImpl class (as defined in WebCore/platform/ArrayImpl.{h,cpp}) has a typo in it&apos;s equality operator which could lead to an incorrect equality test and also a buffer overrun (and therefore a potential crash).

The fix is a trivial change to one line of code. The erroneous code contains the test:
	d-&gt;itemSize == d-&gt;itemSize
which should be:
	d-&gt;itemSize == a.d-&gt;itemSize



In practice, the bug will probably never be seen as the only (current) use of the ArrayImpl class is by DeprecatedArray (and it&apos;s subclass DeprecatedCString). This means that the value of itemSize will always be sizeof(char) (i.e. 1) for both objects being compared and the equality test will work correctly.



On the other hand, this bug appears in the exact same form in much older versions of ArrayImpl. In particular, the existing code has been copied from WebCore/kwq/KWQArrayImpl.cpp (which was copied from WebCore/kwq/KWQArrayImpl.mm).

I didn&apos;t dig too deep but previous versions of WebKit may have additional dependencies on these older classes and cases where itemSize is different. This bug may therefore be more serious in older versions of WebKit.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3331</commentid>
    <comment_count>1</comment_count>
      <attachid>15785</attachid>
    <who name="">rick</who>
    <bug_when>2007-08-01 12:06:36 -0700</bug_when>
    <thetext>Created attachment 15785
Patch that fixes the described bug (includes ChangeLog differences)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3157</commentid>
    <comment_count>2</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2007-08-02 06:17:15 -0700</bug_when>
    <thetext>(In reply to comment #1)
&gt; Created an attachment (id=15785) [edit]
&gt; Patch that fixes the described bug (includes ChangeLog differences)

This really needs a test case.

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3148</commentid>
    <comment_count>3</comment_count>
    <who name="">rick</who>
    <bug_when>2007-08-02 08:04:10 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; (In reply to comment #1)
&gt; &gt; Created an attachment (id=15785) [edit]
&gt; &gt; Patch that fixes the described bug (includes ChangeLog differences)
&gt; 
&gt; This really needs a test case.

Where can I add such a test case? The problem is that the bug wouldn&apos;t show itself with current higher level functionality (i.e. a layout test or a JavaScriptCore test). I couldn&apos;t find anything about adding a lower level C++ test program. For example, something like:

#include &quot;ArrayImpl.h&quot;

int
main()
{
	WebCore::ArrayImpl a(1, 1);
	WebCore::ArrayImpl b(2, 1);
	
	// return 1 on error
	return a == b ? 1 : 0;
}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3142</commentid>
    <comment_count>4</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2007-08-02 09:58:08 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; (In reply to comment #2)
&gt; &gt; This really needs a test case.
&gt; 
&gt; Where can I add such a test case? The problem is that the bug wouldn&apos;t show
&gt; itself with current higher level functionality (i.e. a layout test or a
&gt; JavaScriptCore test). I couldn&apos;t find anything about adding a lower level C++
&gt; test program. For example, something like:

Sorry, by &quot;test case&quot; I meant a layout test (in HTML/JavaScript).  Since that&apos;s not possible, it&apos;s okay not to have one.  :)

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1244</commentid>
    <comment_count>5</comment_count>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2007-08-29 10:45:11 -0700</bug_when>
    <thetext>Landed in r25297.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>15785</attachid>
            <date>2007-08-01 12:06:36 -0700</date>
            <delta_ts>2007-08-02 04:43:45 -0700</delta_ts>
            <desc>Patch that fixes the described bug (includes ChangeLog differences)</desc>
            <filename>patch.txt</filename>
            <type>text/plain</type>
            <size>1122</size>
            <attacher>rick</attacher>
            
              <data encoding="base64">SW5kZXg6IFdlYkNvcmUvQ2hhbmdlTG9nCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIFdlYkNvcmUvQ2hhbmdlTG9n
CShyZXZpc2lvbiAyNDgwNCkKKysrIFdlYkNvcmUvQ2hhbmdlTG9nCSh3b3JraW5nIGNvcHkpCkBA
IC0xLDMgKzEsMTMgQEAKKzIwMDctMDgtMDEgIHJpY2sgIDxyaWNrQHdyaXRoZS5vcmcudWs+CisK
KyAgICAgICAgUmV2aWV3ZWQgYnkgTk9CT0RZIChPT1BTISkuCisKKyAgICAgICAgV0FSTklORzog
Tk8gVEVTVCBDQVNFUyBBRERFRCBPUiBDSEFOR0VECisKKyAgICAgICAgKiBwbGF0Zm9ybS9BcnJh
eUltcGwuY3BwOgorICAgICAgICAoV2ViQ29yZTo6QXJyYXlJbXBsOjpvcGVyYXRvcj09KToKKwlG
aXhlZCB0eXBvIHNvIHRoYXQgY29ycmVjdCB2YXJpYWJsZSBpcyB1c2VkIGluIGVxdWFsaXR5IGNv
bXBhcmlzb24uCisKIDIwMDctMDctMzEgIERhdmlkIEhhcnJpc29uICA8aGFycmlzb25AYXBwbGUu
Y29tPgogCiAgICAgICAgIFJldmlld2VkIGJ5IEp1c3Rpbi4KSW5kZXg6IFdlYkNvcmUvcGxhdGZv
cm0vQXJyYXlJbXBsLmNwcAo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBXZWJDb3JlL3BsYXRmb3JtL0FycmF5SW1w
bC5jcHAJKHJldmlzaW9uIDI0ODAzKQorKysgV2ViQ29yZS9wbGF0Zm9ybS9BcnJheUltcGwuY3Bw
CSh3b3JraW5nIGNvcHkpCkBAIC0xMzgsNyArMTM4LDcgQEAgYm9vbCBBcnJheUltcGw6OmZpbGwo
Y29uc3Qgdm9pZCAqaXRlbSwgaQogCiBib29sIEFycmF5SW1wbDo6b3BlcmF0b3I9PShjb25zdCBB
cnJheUltcGwgJmEpIGNvbnN0CiB7Ci0gICAgcmV0dXJuIGQtPm51bUl0ZW1zID09IGEuZC0+bnVt
SXRlbXMgJiYgZC0+aXRlbVNpemUgPT0gZC0+aXRlbVNpemUKKyAgICByZXR1cm4gZC0+bnVtSXRl
bXMgPT0gYS5kLT5udW1JdGVtcyAmJiBkLT5pdGVtU2l6ZSA9PSBhLmQtPml0ZW1TaXplCiAgICAg
ICAgICYmIChkLT5kYXRhID09IGEuZC0+ZGF0YSB8fCBtZW1jbXAoZC0+ZGF0YSwgYS5kLT5kYXRh
LCBkLT5pdGVtU2l6ZSpkLT5udW1JdGVtcykgPT0gMCk7CiB9CiAK
</data>
<flag name="review"
          id="6591"
          type_id="1"
          status="+"
          setter="timothy"
    />
          </attachment>
      

    </bug>

</bugzilla>