<?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>140427</bug_id>
          
          <creation_ts>2015-01-13 20:49:54 -0800</creation_ts>
          <short_desc>Correct calculation of 16-bit text iterator decode offsets</short_desc>
          <delta_ts>2015-01-14 15:47:36 -0800</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>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</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="Brent Fulgham">bfulgham</reporter>
          <assigned_to name="Brent Fulgham">bfulgham</assigned_to>
          <cc>bfulgham</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1061058</commentid>
    <comment_count>0</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2015-01-13 20:49:54 -0800</bug_when>
    <thetext>The TextCodecUTF8 and TextCodecLatin1 decoding routines have a calculation error in the update to the &apos;destination16&apos; memory location. This was found by static analysis of the code.

The &apos;destination16&apos; variable (in both files) is a pointer to a 16-bit character value, while the &apos;source&apos; value is an 8-bit value.

We updated the &apos;source&apos; pointer by incrementing it by the sizeof(MachineWord), which is the number of UTF8 characters we have consumed during the decode.

However, the &apos;destination16&apos; variable is a UChar* (a 16-bit value). If we increment it by the number of bytes, that has the effect of moving us twice the number of 16-bit characters than we should be.

We should be incrementing by sizeof(MachineWord) / sizeof(UChar).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1061060</commentid>
    <comment_count>1</comment_count>
      <attachid>244576</attachid>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2015-01-13 20:51:56 -0800</bug_when>
    <thetext>Created attachment 244576
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1061064</commentid>
    <comment_count>2</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2015-01-13 20:56:55 -0800</bug_when>
    <thetext>I misunderstood what copyASCIIMachineWord was doing here. The sizeof() is the correct thing to be doing, and the Static Analyzer warning is spurious.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1061366</commentid>
    <comment_count>3</comment_count>
      <attachid>244576</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2015-01-14 15:46:51 -0800</bug_when>
    <thetext>Comment on attachment 244576
Patch

These three fixes look good. Why no regression tests for any of them? Didn’t these bugs cause any symptoms? We normally require regression tests for all bug fixes.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1061368</commentid>
    <comment_count>4</comment_count>
      <attachid>244576</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2015-01-14 15:47:36 -0800</bug_when>
    <thetext>Comment on attachment 244576
Patch

Oops, as you said, the warning was wrong for the destination16 lines!</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>244576</attachid>
            <date>2015-01-13 20:51:56 -0800</date>
            <delta_ts>2015-01-14 15:47:36 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-140427-20150113205901.patch</filename>
            <type>text/plain</type>
            <size>2693</size>
            <attacher name="Brent Fulgham">bfulgham</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09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JTWFjaGlu
ZVdvcmQoZGVzdGluYXRpb24xNiwgc291cmNlKTsKICAgICAgICAgICAgICAgICAgICAgc291cmNl
ICs9IHNpemVvZihNYWNoaW5lV29yZCk7Ci0gICAgICAgICAgICAgICAgICAgIGRlc3RpbmF0aW9u
MTYgKz0gc2l6ZW9mKE1hY2hpbmVXb3JkKTsKKyAgICAgICAgICAgICAgICAgICAgZGVzdGluYXRp
b24xNiArPSBzaXplb2YoTWFjaGluZVdvcmQpIC8gc2l6ZW9mKFVDaGFyKTsKICAgICAgICAgICAg
ICAgICB9CiAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgaWYgKHNvdXJjZSA9PSBl
bmQpCkluZGV4OiBTb3VyY2UvV2ViQ29yZS9wbGF0Zm9ybS90ZXh0L1RleHRDb2RlY1VURjguY3Bw
Cj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT0KLS0tIFNvdXJjZS9XZWJDb3JlL3BsYXRmb3JtL3RleHQvVGV4dENvZGVjVVRG
OC5jcHAJKHJldmlzaW9uIDE3ODM2NCkKKysrIFNvdXJjZS9XZWJDb3JlL3BsYXRmb3JtL3RleHQv
VGV4dENvZGVjVVRGOC5jcHAJKHdvcmtpbmcgY29weSkKQEAgLTM3Niw3ICszNzYsNyBAQCB1cENv
bnZlcnRUbzE2Qml0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAg
ICAgICAgICAgICAgICAgICAgY29weUFTQ0lJTWFjaGluZVdvcmQoZGVzdGluYXRpb24xNiwgc291
cmNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZSArPSBzaXplb2YoTWFjaGluZVdv
cmQpOwotICAgICAgICAgICAgICAgICAgICAgICAgZGVzdGluYXRpb24xNiArPSBzaXplb2YoTWFj
aGluZVdvcmQpOworICAgICAgICAgICAgICAgICAgICAgICAgZGVzdGluYXRpb24xNiArPSBzaXpl
b2YoTWFjaGluZVdvcmQpIC8gc2l6ZW9mKFVDaGFyKTsKICAgICAgICAgICAgICAgICAgICAgfQog
ICAgICAgICAgICAgICAgICAgICBpZiAoc291cmNlID09IGVuZCkKICAgICAgICAgICAgICAgICAg
ICAgICAgIGJyZWFrOwo=
</data>
<flag name="review"
          id="269520"
          type_id="1"
          status="-"
          setter="darin"
    />
          </attachment>
      

    </bug>

</bugzilla>