<?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>17814</bug_id>
          
          <creation_ts>2008-03-12 16:32:14 -0700</creation_ts>
          <short_desc>Reading past end of string, for certain malformed &lt;?xml ..?&gt; tags</short_desc>
          <delta_ts>2008-10-16 01:47:10 -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>Page Loading</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>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Eric Roman">eroman</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>mrowe</cc>
    
    <cc>oliver</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>73531</commentid>
    <comment_count>0</comment_count>
    <who name="Eric Roman">eroman</who>
    <bug_when>2008-03-12 16:32:14 -0700</bug_when>
    <thetext>This applies to the &quot;Safari-3-1-branch&quot;.

when parsing malformed &lt;?xml ...?&gt; tags, strict bounds checking is not enforced, so can read past the end of string.

For example &quot;http://www.exitfest.org&quot; does not have a terminal question-mark:
 &lt;?xml version=&quot;1.0&quot; encoding=&quot;iso-8859-2&quot;&gt;

And has caused a crash for me.

This problem looks to have been fixed in:
trunk/WebCore/loader/TextResourceDecoder.cpp @ r30535

Perhaps this is worth back-porting to the 3.1 branch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73532</commentid>
    <comment_count>1</comment_count>
      <attachid>19718</attachid>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2008-03-12 17:20:03 -0700</bug_when>
    <thetext>Created attachment 19718
test case (crashes browser)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73534</commentid>
    <comment_count>2</comment_count>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2008-03-12 17:29:23 -0700</bug_when>
    <thetext>&lt;rdar://problem/5796571&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73535</commentid>
    <comment_count>3</comment_count>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2008-03-12 17:44:04 -0700</bug_when>
    <thetext>This does not occur in trunk.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73557</commentid>
    <comment_count>4</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2008-03-13 03:16:12 -0700</bug_when>
    <thetext>Where you running an instrumented build of some kind?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73614</commentid>
    <comment_count>5</comment_count>
    <who name="Eric Roman">eroman</who>
    <bug_when>2008-03-13 12:00:22 -0700</bug_when>
    <thetext>The following test should repro the problem:

$ cat broken.html
&lt;?xml version=&quot;1.0&quot; encoding=&quot;iso-8859-2&gt;

(Apologies, the example I posted earlier was for an outdated version of webkit)

I was running webkit with Purify tool on Windows, and it showed the problem to be in findXMLEncoding():

    // Find the trailing quotation mark.
    int end = pos;
    while (str[end] != quoteMark)    &lt;----- Access Violation
        ++end;

Since the input contains no terminal quote mark, it reads past end of string.

In trunk I see that this is fixed, as the line now reads:

    while (end &lt; len &amp;&amp; str[end] != quoteMark)



(At some point I was repro-ing this with missing question mark too, but this seems to have gone away when I synched up my client recentish.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73615</commentid>
    <comment_count>6</comment_count>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2008-03-13 12:03:24 -0700</bug_when>
    <thetext>So in other words, the test case does *not* crash the browser but it *does* trigger errors from memory checking tools (Purify, Valgrind, etc)?  </thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73649</commentid>
    <comment_count>7</comment_count>
    <who name="Oliver Hunt">oliver</who>
    <bug_when>2008-03-13 16:42:42 -0700</bug_when>
    <thetext>After keeping the test case as my homepage for a few days i eventually hit this crash:
0   com.apple.WebCore             	0x90989fa7 WebCore::TextResourceDecoder::checkForHeadCharset(char const*, unsigned long, bool&amp;) + 935
1   com.apple.WebCore             	0x90989a47 WebCore::TextResourceDecoder::decode(char const*, unsigned long) + 679
2   com.apple.WebCore             	0x90987f7e WebCore::FrameLoader::write(char const*, int, bool) + 190
3   com.apple.WebCore             	0x909cab67 WebCore::FrameLoader::addData(char const*, int) + 39
4   com.apple.WebCore             	0x909c4ddd -[WebCoreFrameBridge receivedData:textEncodingName:] + 205
5   com.apple.WebKit              	0x9544c900 -[WebHTMLRepresentation receivedData:withDataSource:] + 224
6   com.apple.WebKit              	0x9544c7bb -[WebDataSource(WebInternal) _receivedData:] + 91
7   com.apple.WebKit              	0x9544c739 WebFrameLoaderClient::committedLoad(WebCore::DocumentLoader*, char const*, int) + 137
8   com.apple.WebCore             	0x909c1d86 WebCore::DocumentLoader::commitLoad(char const*, int) + 70
9   com.apple.WebCore             	0x909c1925 WebCore::ResourceLoader::didReceiveData(char const*, int, long long, bool) + 69
10  com.apple.WebCore             	0x909c1897 WebCore::MainResourceLoader::didReceiveData(char const*, int, long long, bool) + 71
11  com.apple.WebCore             	0x909c1848 WebCore::ResourceLoader::didReceiveData(WebCore::ResourceHandle*, char const*, int, int) + 56
12  com.apple.Foundation          	0x950383b7 -[NSURLConnection(NSURLConnectionReallyInternal) sendDidReceiveData:originalLength:] + 119
13  com.apple.Foundation          	0x9503831e _NSURLConnectionDidReceiveData + 94
14  com.apple.CFNetwork           	0x931a90af sendDidReceiveDataCallback + 518
15  com.apple.CFNetwork           	0x931a676d _CFURLConnectionSendCallbacks + 1559
16  com.apple.CFNetwork           	0x931a60d9 muxerSourcePerform + 283
17  com.apple.CoreFoundation      	0x933a862e CFRunLoopRunSpecific + 3166
18  com.apple.CoreFoundation      	0x933a8d18 CFRunLoopRunInMode + 88
19  com.apple.HIToolbox           	0x913906a0 RunCurrentEventLoopInMode + 283
20  com.apple.HIToolbox           	0x913904b9 ReceiveNextEventCommon + 374
21  com.apple.HIToolbox           	0x9139032d BlockUntilNextEventMatchingListInMode + 106
22  com.apple.AppKit              	0x942457d9 _DPSNextEvent + 657
23  com.apple.AppKit              	0x9424508e -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
24  com.apple.Safari              	0x0000804e 0x1000 + 28750
25  com.apple.AppKit              	0x9423e0c5 -[NSApplication run] + 795
26  com.apple.AppKit              	0x9420b30a NSApplicationMain + 574
27  com.apple.Safari              	0x000b9a76 0x1000 + 756342

Thread 1:
0   libSystem.B.dylib             	0x95e2cbce __semwait_signal + 10
1   libSystem.B.dylib             	0x95e578cd pthread_cond_wait$UNIX2003 + 73
2   com.apple.WebCore             	0x9094f56f WebCore::IconDatabase::syncThreadMainLoop() + 239
3   com.apple.WebCore             	0x90907cd5 WebCore::IconDatabase::iconDatabaseSyncThread() + 181
4   libSystem.B.dylib             	0x95e56c55 _pthread_start + 321
5   libSystem.B.dylib             	0x95e56b12 thread_start + 34

Thread 2:
0   libSystem.B.dylib             	0x95e259e6 mach_msg_trap + 10
1   libSystem.B.dylib             	0x95e2d1dc mach_msg + 72
2   com.apple.CoreFoundation      	0x933a80de CFRunLoopRunSpecific + 1806
3   com.apple.CoreFoundation      	0x933a8d18 CFRunLoopRunInMode + 88
4   com.apple.CFNetwork           	0x931a16cc CFURLCacheWorkerThread(void*) + 396
5   libSystem.B.dylib             	0x95e56c55 _pthread_start + 321
6   libSystem.B.dylib             	0x95e56b12 thread_start + 34

Thread 3:
0   libSystem.B.dylib             	0x95e259e6 mach_msg_trap + 10
1   libSystem.B.dylib             	0x95e2d1dc mach_msg + 72
2   com.apple.CoreFoundation      	0x933a80de CFRunLoopRunSpecific + 1806
3   com.apple.CoreFoundation      	0x933a8d18 CFRunLoopRunInMode + 88
4   com.apple.Foundation          	0x95036ac0 +[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:] + 320
5   com.apple.Foundation          	0x94fd35ad -[NSThread main] + 45
6   com.apple.Foundation          	0x94fd3154 __NSThread__main__ + 308
7   libSystem.B.dylib             	0x95e56c55 _pthread_start + 321
8   libSystem.B.dylib             	0x95e56b12 thread_start + 34

Thread 4:
0   libSystem.B.dylib             	0x95e75b3a select$DARWIN_EXTSN + 10
1   libSystem.B.dylib             	0x95e56c55 _pthread_start + 321
2   libSystem.B.dylib             	0x95e56b12 thread_start + 34

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73717</commentid>
    <comment_count>8</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2008-03-14 02:38:48 -0700</bug_when>
    <thetext>(In reply to comment #7)
&gt; After keeping the test case as my homepage for a few days i eventually hit this
&gt; crash:
&gt; 0   com.apple.WebCore                   0x90989fa7
&gt; WebCore::TextResourceDecoder::checkForHeadCharset(char const*, unsigned long,
&gt; bool&amp;) + 935

Are you sure this is the same issue?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95520</commentid>
    <comment_count>9</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2008-10-16 01:47:10 -0700</bug_when>
    <thetext>There doesn&apos;t seem to be a pressing reason to backport this to 3.1 (for all we know, this is neither a security issue, nor a frequent crash). As this is known to be fixed in trunk, closing as FIXED. The test case is going to be landed as part of bug 21407.

As mentioned before, the issue Oliver is reporting was probably a different one, and we haven&apos;t seen it happen recently anyway.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>19718</attachid>
            <date>2008-03-12 17:20:03 -0700</date>
            <delta_ts>2008-03-12 17:20:03 -0700</delta_ts>
            <desc>test case (crashes browser)</desc>
            <filename>bad-xml-entity.html</filename>
            <type>text/html</type>
            <size>331</size>
            <attacher name="Eric Seidel (no email)">eric</attacher>
            
              <data encoding="base64">PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMiI+CjxodG1sIHhtbG5zPSJo
dHRwOi8vd3d3LnczLm9yZy8xOTk5L3hodG1sIj4KPGJvZHk+CjxwPlJFUFJPRFVDSUJMRSBDUkFT
SDogT21pdHRpbmcgdGVybWluYWwgcXVlc3Rpb24gbWFyayBpbiB4bWwgdGFnIGNhdXNlcyBhY2Nl
c3MgdmlvbGF0aW9uLjwvcD4KPHNjcmlwdD4KaWYgKHdpbmRvdy5sYXlvdXRUZXN0Q29udHJvbGxl
cikKICBsYXlvdXRUZXN0Q29udHJvbGxlci5kdW1wQXNUZXh0KCk7Cjwvc2NyaXB0Pgo8cD5JZiB5
b3UgZG9uJ3QgY3Jhc2gsIHlvdSBwYXNzLjwvcD4KPC9ib2R5Pgo8L2h0bWw+Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>