Changeset 242352 in webkit


Ignore:
Timestamp:
Mar 4, 2019 6:30:46 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

WebDriver: fix String not terminated with null caracter
https://bugs.webkit.org/show_bug.cgi?id=195274

Patch by Karl Leplat <karl.leplat_ext@softathome.com> on 2019-03-04
Reviewed by Carlos Garcia Campos.

This has been detected by an exception returned by the function
evaluateJavaScriptFunction with the message :
[native code]: JS ERROR SyntaxError: Unexpected keyword 'function'. Expected ')' to end a compound expression.
keyword 'function' has been initialized with a string that come from char array, not a null-terminated string.

  • Session.cpp:

(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::findElements):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::elementClear):

Location:
trunk/Source/WebDriver
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebDriver/ChangeLog

    r240786 r242352  
     12019-03-04  Karl Leplat  <karl.leplat_ext@softathome.com>
     2
     3        WebDriver: fix String not terminated with null caracter
     4        https://bugs.webkit.org/show_bug.cgi?id=195274
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        This has been detected by an exception returned by the function
     9        evaluateJavaScriptFunction with the message :
     10        [native code]: JS ERROR SyntaxError: Unexpected keyword 'function'. Expected ')' to end a compound expression.
     11        keyword 'function' has been initialized with a string that come from char array, not a null-terminated string.
     12
     13        * Session.cpp:
     14        (WebDriver::Session::fullscreenWindow):
     15        (WebDriver::Session::findElements):
     16        (WebDriver::Session::isElementSelected):
     17        (WebDriver::Session::isElementDisplayed):
     18        (WebDriver::Session::getElementAttribute):
     19        (WebDriver::Session::elementClear):
     20
    1212019-01-31  Zan Dobersek  <zdobersek@igalia.com>
    222
  • trunk/Source/WebDriver/Session.cpp

    r239610 r242352  
    840840        RefPtr<JSON::Object> parameters = JSON::Object::create();
    841841        parameters->setString("browsingContextHandle"_s, m_toplevelBrowsingContext.value());
    842         parameters->setString("function"_s, EnterFullscreenJavaScript);
     842        parameters->setString("function"_s, String(EnterFullscreenJavaScript, sizeof(EnterFullscreenJavaScript)));
    843843        parameters->setArray("arguments"_s, JSON::Array::create());
    844844        parameters->setBoolean("expectsImplicitCallbackArgument"_s, true);
     
    10031003        if (m_currentBrowsingContext)
    10041004            parameters->setString("frameHandle"_s, m_currentBrowsingContext.value());
    1005         parameters->setString("function"_s, FindNodesJavaScript);
     1005        parameters->setString("function"_s, String(FindNodesJavaScript, sizeof(FindNodesJavaScript)));
    10061006        parameters->setArray("arguments"_s, WTFMove(arguments));
    10071007        parameters->setBoolean("expectsImplicitCallbackArgument"_s, true);
     
    11171117        if (m_currentBrowsingContext)
    11181118            parameters->setString("frameHandle"_s, m_currentBrowsingContext.value());
    1119         parameters->setString("function"_s, ElementAttributeJavaScript);
     1119        parameters->setString("function"_s, String(ElementAttributeJavaScript, sizeof(ElementAttributeJavaScript)));
    11201120        parameters->setArray("arguments"_s, WTFMove(arguments));
    11211121        m_host->sendCommandToBackend("evaluateJavaScriptFunction"_s, WTFMove(parameters), [protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) {
     
    13181318        if (m_currentBrowsingContext)
    13191319            parameters->setString("frameHandle"_s, m_currentBrowsingContext.value());
    1320         parameters->setString("function"_s, ElementDisplayedJavaScript);
     1320        parameters->setString("function"_s, String(ElementDisplayedJavaScript, sizeof(ElementDisplayedJavaScript)));
    13211321        parameters->setArray("arguments"_s, WTFMove(arguments));
    13221322        m_host->sendCommandToBackend("evaluateJavaScriptFunction"_s, WTFMove(parameters), [protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) {
     
    13601360        if (m_currentBrowsingContext)
    13611361            parameters->setString("frameHandle"_s, m_currentBrowsingContext.value());
    1362         parameters->setString("function"_s, ElementAttributeJavaScript);
     1362        parameters->setString("function"_s, String(ElementAttributeJavaScript, sizeof(ElementAttributeJavaScript)));
    13631363        parameters->setArray("arguments"_s, WTFMove(arguments));
    13641364        m_host->sendCommandToBackend("evaluateJavaScriptFunction"_s, WTFMove(parameters), [protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) {
     
    15861586        if (m_currentBrowsingContext)
    15871587            parameters->setString("frameHandle"_s, m_currentBrowsingContext.value());
    1588         parameters->setString("function"_s, FormElementClearJavaScript);
     1588        parameters->setString("function"_s, String(FormElementClearJavaScript, sizeof(FormElementClearJavaScript)));
    15891589        parameters->setArray("arguments"_s, WTFMove(arguments));
    15901590        m_host->sendCommandToBackend("evaluateJavaScriptFunction"_s, WTFMove(parameters), [protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) {
Note: See TracChangeset for help on using the changeset viewer.