WebDriver: deserializeTimeouts should fail if the value is not integer
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Oct 2017 07:11:56 +0000 (07:11 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Oct 2017 07:11:56 +0000 (07:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=178866

Reviewed by Brian Burg.

If value is not an integer, or it is less than 0 or greater than 2^64 – 1, return error with error code invalid
argument.
https://w3c.github.io/webdriver/webdriver-spec.html#dfn-deserialize-as-a-timeout

Fixes: imported/w3c/webdriver/tests/sessions/new_session/invalid_capabilities.py::test_invalid_values[timeouts-value59-body0]
       imported/w3c/webdriver/tests/sessions/new_session/invalid_capabilities.py::test_invalid_values[timeouts-value59-body1]

* WebDriverService.cpp:
(WebDriver::deserializeTimeouts):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224089 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebDriver/ChangeLog
Source/WebDriver/WebDriverService.cpp

index c39f0f2..eace953 100644 (file)
@@ -1,5 +1,22 @@
 2017-10-27  Carlos Garcia Campos  <cgarcia@igalia.com>
 
+        WebDriver: deserializeTimeouts should fail if the value is not integer
+        https://bugs.webkit.org/show_bug.cgi?id=178866
+
+        Reviewed by Brian Burg.
+
+        If value is not an integer, or it is less than 0 or greater than 2^64 – 1, return error with error code invalid
+        argument.
+        https://w3c.github.io/webdriver/webdriver-spec.html#dfn-deserialize-as-a-timeout
+
+        Fixes: imported/w3c/webdriver/tests/sessions/new_session/invalid_capabilities.py::test_invalid_values[timeouts-value59-body0]
+               imported/w3c/webdriver/tests/sessions/new_session/invalid_capabilities.py::test_invalid_values[timeouts-value59-body1]
+
+        * WebDriverService.cpp:
+        (WebDriver::deserializeTimeouts):
+
+2017-10-27  Carlos Garcia Campos  <cgarcia@igalia.com>
+
         WebDriver: failing to process capabilities should produce InvalidArgument error not SessionNotCreated
         https://bugs.webkit.org/show_bug.cgi?id=178864
 
index 4862eac..bbc20c5 100644 (file)
@@ -283,7 +283,7 @@ static std::optional<Timeouts> deserializeTimeouts(InspectorObject& timeoutsObje
             continue;
 
         int timeoutMS;
-        if (!it->value->asInteger(timeoutMS) || timeoutMS < 0 || timeoutMS > INT_MAX)
+        if (it->value->type() != InspectorValue::Type::Integer || !it->value->asInteger(timeoutMS) || timeoutMS < 0 || timeoutMS > INT_MAX)
             return std::nullopt;
 
         if (it->key == "script")