WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
176357
Missing break in URLParser
https://bugs.webkit.org/show_bug.cgi?id=176357
Summary
Missing break in URLParser
Tomas Popela
Reported
2017-09-05 03:01:21 PDT
Found by Coverity scan: 1. webkitgtk-2.16.6/Source/WebCore/platform/URLParser.cpp:1233: value_overwrite: Overwriting previous write to "state" with value "void WebCore::URLParser::parse(unsigned short const *, unsigned int, WebCore::URL const &, WebCore::TextEncoding const &)::State::Scheme (instance 69995)". 2. webkitgtk-2.16.6/Source/WebCore/platform/URLParser.cpp:1230: assigned_value: Assigning value "void WebCore::URLParser::parse(unsigned short const *, unsigned int, WebCore::URL const &, WebCore::TextEncoding const &)::State::NoScheme (instance 69996)" to "state" here, but that stored value is overwritten before it can be used. # 1228| if (c.atEnd()) { # 1229| m_asciiBuffer.clear(); # 1230|-> state = State::NoScheme; # 1231| c = beginAfterControlAndSpace; # 1232| }
Attachments
Patch
(1.38 KB, patch)
2017-09-05 03:04 PDT
,
Tomas Popela
no flags
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Tomas Popela
Comment 1
2017-09-05 03:04:10 PDT
Created
attachment 319889
[details]
Patch
Alexey Proskuryakov
Comment 2
2017-09-05 19:49:16 PDT
Comment on
attachment 319889
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=319889&action=review
> Source/WebCore/ChangeLog:9 > + Add a missing break so the currently set state is not overwritten > + after the block. Found by Coverity scan.
Does this change observable behavior? If so, please add a test.
Darin Adler
Comment 3
2017-09-05 20:56:46 PDT
Comment on
attachment 319889
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=319889&action=review
>> Source/WebCore/ChangeLog:9 >> + after the block. Found by Coverity scan. > > 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!
Tomas Popela
Comment 4
2017-09-06 05:46:41 PDT
(In reply to Darin Adler from
comment #3
)
> Comment on
attachment 319889
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=319889&action=review
> > >> Source/WebCore/ChangeLog:9 > >> + after the block. Found by Coverity scan. > > > > 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!
I don'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 'break' 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 'break'. The state is set to NoScheme, the input restarted, buffer cleared and the state is again changed, but to Scheme (due to missing 'break'). 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 'break' added in this patch. So the main difference is that without the 'break' 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.
Darin Adler
Comment 5
2017-09-06 09:08:55 PDT
Comment on
attachment 319889
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=319889&action=review
>>>> Source/WebCore/ChangeLog:9 >>>> + after the block. Found by Coverity scan. >>> >>> 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! > > I don'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 'break' 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 'break'. The state is set to NoScheme, the input restarted, buffer cleared and the state is again changed, but to Scheme (due to missing 'break'). 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 'break' added in this patch. So the main difference is that without the 'break' 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.
WebKit Commit Bot
Comment 6
2017-09-06 09:38:00 PDT
Comment on
attachment 319889
[details]
Patch Clearing flags on attachment: 319889 Committed
r221677
: <
http://trac.webkit.org/changeset/221677
>
WebKit Commit Bot
Comment 7
2017-09-06 09:38:02 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 8
2017-09-27 12:37:23 PDT
<
rdar://problem/34693623
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug