<?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>176357</bug_id>
          
          <creation_ts>2017-09-05 03:01:21 -0700</creation_ts>
          <short_desc>Missing break in URLParser</short_desc>
          <delta_ts>2017-09-27 12:37:23 -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>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</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>1</everconfirmed>
          <reporter name="Tomas Popela">tpopela</reporter>
          <assigned_to name="Tomas Popela">tpopela</assigned_to>
          <cc>achristensen</cc>
    
    <cc>ap</cc>
    
    <cc>commit-queue</cc>
    
    <cc>darin</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1345390</commentid>
    <comment_count>0</comment_count>
    <who name="Tomas Popela">tpopela</who>
    <bug_when>2017-09-05 03:01:21 -0700</bug_when>
    <thetext>Found by Coverity scan:

1. webkitgtk-2.16.6/Source/WebCore/platform/URLParser.cpp:1233: value_overwrite: Overwriting previous write to &quot;state&quot; with value &quot;void WebCore::URLParser::parse(unsigned short const *, unsigned int, WebCore::URL const &amp;, WebCore::TextEncoding const &amp;)::State::Scheme (instance 69995)&quot;.
2. webkitgtk-2.16.6/Source/WebCore/platform/URLParser.cpp:1230: assigned_value: Assigning value &quot;void WebCore::URLParser::parse(unsigned short const *, unsigned int, WebCore::URL const &amp;, WebCore::TextEncoding const &amp;)::State::NoScheme (instance 69996)&quot; to &quot;state&quot; here, but that stored value is overwritten before it can be used.
#  1228|                   if (c.atEnd()) {
#  1229|                       m_asciiBuffer.clear();
#  1230|-&gt;                     state = State::NoScheme;
#  1231|                       c = beginAfterControlAndSpace;
#  1232|                   }</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1345391</commentid>
    <comment_count>1</comment_count>
      <attachid>319889</attachid>
    <who name="Tomas Popela">tpopela</who>
    <bug_when>2017-09-05 03:04:10 -0700</bug_when>
    <thetext>Created attachment 319889
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1345770</commentid>
    <comment_count>2</comment_count>
      <attachid>319889</attachid>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2017-09-05 19:49:16 -0700</bug_when>
    <thetext>Comment on attachment 319889
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=319889&amp;action=review

&gt; Source/WebCore/ChangeLog:9
&gt; +        Add a missing break so the currently set state is not overwritten
&gt; +        after the block. Found by Coverity scan.

Does this change observable behavior? If so, please add a test.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1345794</commentid>
    <comment_count>3</comment_count>
      <attachid>319889</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2017-09-05 20:56:46 -0700</bug_when>
    <thetext>Comment on attachment 319889
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=319889&amp;action=review

&gt;&gt; Source/WebCore/ChangeLog:9
&gt;&gt; +        after the block. Found by Coverity scan.
&gt; 
&gt; Does this change observable behavior? If so, please add a test.

Yes, it’s a great catch, but we do want a regression test to show what we were doing wrong!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1345894</commentid>
    <comment_count>4</comment_count>
    <who name="Tomas Popela">tpopela</who>
    <bug_when>2017-09-06 05:46:41 -0700</bug_when>
    <thetext>(In reply to Darin Adler from comment #3)
&gt; Comment on attachment 319889 [details]
&gt; Patch
&gt; 
&gt; View in context:
&gt; https://bugs.webkit.org/attachment.cgi?id=319889&amp;action=review
&gt; 
&gt; &gt;&gt; Source/WebCore/ChangeLog:9
&gt; &gt;&gt; +        after the block. Found by Coverity scan.
&gt; &gt; 
&gt; &gt; Does this change observable behavior? If so, please add a test.
&gt; 
&gt; Yes, it’s a great catch, but we do want a regression test to show what we
&gt; were doing wrong!

I don&apos;t think we need test case if I got the context right:

From looking at the code the sequence to get to the part where the &apos;break&apos; is missing we have to process the input that contains one character. We will start with state SchemeStart (log this state), process the character (that has to be ASCII lowercase alpha) and append to the buffer. Now we will move to the next character and as there is none (c.atEnd() is true) we will move to the branch with missing &apos;break&apos;. The state is set to NoScheme, the input restarted, buffer cleared and the state is again changed, but to Scheme (due to missing &apos;break&apos;). We continue in the loop (!c.atEnd()), now with the Scheme state. The state is logged and the first condition for Scheme case is isValidSchemeCharacter(). We know that the input contains ASCII lowercase alpha and that means that it is also a valid scheme character. The character is appended to the buffer and we move to the next character in the input, but as there is none then the state is set to NoScheme, the input restarted, buffer cleared. We again continue in the loop, now with the state NoScheme. So we got to the same point where we would end with the &apos;break&apos; added in this patch. So the main difference is that without the &apos;break&apos; there is an extra log message mentioning Scheme state. I should note that the url parser debugging is disabled by default, so in the default configuration there is no difference while running URLParser with or without this patch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1345946</commentid>
    <comment_count>5</comment_count>
      <attachid>319889</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2017-09-06 09:08:55 -0700</bug_when>
    <thetext>Comment on attachment 319889
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=319889&amp;action=review

&gt;&gt;&gt;&gt; Source/WebCore/ChangeLog:9
&gt;&gt;&gt;&gt; +        after the block. Found by Coverity scan.
&gt;&gt;&gt; 
&gt;&gt;&gt; Does this change observable behavior? If so, please add a test.
&gt;&gt; 
&gt;&gt; Yes, it’s a great catch, but we do want a regression test to show what we were doing wrong!
&gt; 
&gt; I don&apos;t think we need test case if I got the context right:
&gt; 
&gt; From looking at the code the sequence to get to the part where the &apos;break&apos; is missing we have to process the input that contains one character. We will start with state SchemeStart (log this state), process the character (that has to be ASCII lowercase alpha) and append to the buffer. Now we will move to the next character and as there is none (c.atEnd() is true) we will move to the branch with missing &apos;break&apos;. The state is set to NoScheme, the input restarted, buffer cleared and the state is again changed, but to Scheme (due to missing &apos;break&apos;). We continue in the loop (!c.atEnd()), now with the Scheme state. The state is logged and the first condition for Scheme case is isValidSchemeCharacter(). We know that the input contains ASCII lowercase alpha and that means that it is also a valid scheme character. The character is appended to the buffer and we move to the next character in the input, but as there is none then the state is set to NoScheme, the input restarted, buffer cleared. We again continue in the loop, now with the state NoScheme. So we got to the same point where we would end with the &apos;break&apos; added in this patch. So the main difference is that without the &apos;break&apos; there is an extra log message mentioning Scheme state. I should note that the url parser debugging is disabled by default, so in the default configuration there is no difference while running URLParser with or without this patch.

Yes, makes sense. This mistake did not result in incorrect behavior, just a *tiny* bit less efficient.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1345962</commentid>
    <comment_count>6</comment_count>
      <attachid>319889</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2017-09-06 09:38:00 -0700</bug_when>
    <thetext>Comment on attachment 319889
Patch

Clearing flags on attachment: 319889

Committed r221677: &lt;http://trac.webkit.org/changeset/221677&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1345963</commentid>
    <comment_count>7</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2017-09-06 09:38:02 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1353536</commentid>
    <comment_count>8</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2017-09-27 12:37:23 -0700</bug_when>
    <thetext>&lt;rdar://problem/34693623&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>319889</attachid>
            <date>2017-09-05 03:04:10 -0700</date>
            <delta_ts>2017-09-06 09:38:00 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-176357-20170905120409.patch</filename>
            <type>text/plain</type>
            <size>1409</size>
            <attacher name="Tomas Popela">tpopela</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjIxNjEyCmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggYzk5NmE1NWQyMjllYTI1
MTA3ZmQ4MThjOGY2NGFlMWNkODdlN2QzYS4uNGYxYThmNDFhMGJhNTQyNDUyNTFkZDQ1ZmFhMDBl
NjI1MzVkZDYwMSAxMDA2NDQKLS0tIGEvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCisrKyBiL1Nv
dXJjZS9XZWJDb3JlL0NoYW5nZUxvZwpAQCAtMSwzICsxLDE2IEBACisyMDE3LTA5LTA1ICBUb21h
cyBQb3BlbGEgIDx0cG9wZWxhQHJlZGhhdC5jb20+CisKKyAgICAgICAgTWlzc2luZyBicmVhayBp
biBVUkxQYXJzZXIKKyAgICAgICAgaHR0cHM6Ly9idWdzLndlYmtpdC5vcmcvc2hvd19idWcuY2dp
P2lkPTE3NjM1NworCisgICAgICAgIFJldmlld2VkIGJ5IE5PQk9EWSAoT09QUyEpLgorCisgICAg
ICAgIEFkZCBhIG1pc3NpbmcgYnJlYWsgc28gdGhlIGN1cnJlbnRseSBzZXQgc3RhdGUgaXMgbm90
IG92ZXJ3cml0dGVuCisgICAgICAgIGFmdGVyIHRoZSBibG9jay4gRm91bmQgYnkgQ292ZXJpdHkg
c2Nhbi4KKworICAgICAgICAqIHBsYXRmb3JtL1VSTFBhcnNlci5jcHA6CisgICAgICAgIChX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