aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules/skjson/src/SkJSONTest.cpp
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2018-06-15 16:42:09 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-15 21:04:35 +0000
commit0052a318680af83242d7af67acd3b055bde740c5 (patch)
tree15c6763d6a74d6d4279ee623b0033dbf6e57ce7d /modules/skjson/src/SkJSONTest.cpp
parent37eef455fbc258c1009f95f8b28ce2ff45f2534e (diff)
[skjson] Detect end-of-input for unbalanced strings
We currently blow through string chars without checking for end-of-input. Maybe we could avoid this upfront, when we locate the stop char: try to determine if it's part of an unterminated string, fail immediately if so. Figuring out if the tail is an unterminated string seems intractable though (requires arbitrarily deep tail parsing). That brings us to plan B: * treat scope-closing tokens (} & ]) as string terminators (we know end-of-input points to one of these for sure) * adjust matchString() to check for end-of-input Bug: oss-fuzz:8899 Change-Id: Ic0a88a405548e8724b76faca525099a7e7037341 Reviewed-on: https://skia-review.googlesource.com/135145 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Kevin Lubick <kjlubick@google.com>
Diffstat (limited to 'modules/skjson/src/SkJSONTest.cpp')
-rw-r--r--modules/skjson/src/SkJSONTest.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/modules/skjson/src/SkJSONTest.cpp b/modules/skjson/src/SkJSONTest.cpp
index 1aaa278fb8..df04ac3529 100644
--- a/modules/skjson/src/SkJSONTest.cpp
+++ b/modules/skjson/src/SkJSONTest.cpp
@@ -32,6 +32,8 @@ DEF_TEST(SkJSON_Parse, reporter) {
{ "{}f" , nullptr },
{ "{]" , nullptr },
{ "[}" , nullptr },
+ { "{\"}" , nullptr },
+ { "[\"]" , nullptr },
{ "1" , nullptr },
{ "true" , nullptr },
{ "false", nullptr },
@@ -68,6 +70,7 @@ DEF_TEST(SkJSON_Parse, reporter) {
{ "[ 1 ]" , "[1]" },
{ "[ 1.248 ]" , "[1.248]" },
{ "[ \"\" ]" , "[\"\"]" },
+ { "[ \"foo{bar}baz\" ]" , "[\"foo{bar}baz\"]" },
{ "[ \" f o o \" ]" , "[\" f o o \"]" },
{ "[ \"123456\" ]" , "[\"123456\"]" },
{ "[ \"1234567\" ]" , "[\"1234567\"]" },
@@ -78,6 +81,7 @@ DEF_TEST(SkJSON_Parse, reporter) {
{ "{}" , "{}" },
{ " \n\r\t { \n\r\t } \n\r\t " , "{}" },
{ "{ \"k\" : null }" , "{\"k\":null}" },
+ { "{ \"foo{\" : \"bar}baz\" }" , "{\"foo{\":\"bar}baz\"}" },
{ "{ \"k1\" : null, \"k2 \":0 }", "{\"k1\":null,\"k2 \":0}" },
{ "{ \"k1\" : null, \"k1\":0 }" , "{\"k1\":null,\"k1\":0}" },