aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/json
diff options
context:
space:
mode:
authorGravatar Yang Gao <yangg@google.com>2016-04-01 07:25:27 +0000
committerGravatar Yang Gao <yangg@google.com>2016-04-01 07:25:27 +0000
commita1821d64130288db642eb185cb013346f6c62ec6 (patch)
treead6cdf6aa904d82a7b29599f451a07c89fef332d /test/core/json
parent9cedd3fb6efd5dd45fb35744f3450d63e3002334 (diff)
parent7661da5b417130262ded988b2f881ab619d3b244 (diff)
Merge branch 'master' into hpack_table
Diffstat (limited to 'test/core/json')
-rw-r--r--test/core/json/corpus/15a8f2e7f94aa00b46f1b991416aa015dd6335801
-rw-r--r--test/core/json/corpus/56cd60743c2cee939f5f357905bd36ec9363f4411
-rw-r--r--test/core/json/corpus/743e89b768af4bd591ea7228118550b1bfb8e7d11
-rw-r--r--test/core/json/corpus/775e8ffda1f5d340dba472d06dc7c8bf8159e3791
-rw-r--r--test/core/json/corpus/8d952ec2e33b2a6a1c7876898719a610f55463881
-rw-r--r--test/core/json/corpus/a0d4af29c6c223b48fe34d6a09b3a7466242f33c1
-rw-r--r--test/core/json/fuzzer.c41
-rw-r--r--test/core/json/json_rewrite.c2
-rw-r--r--test/core/json/json_rewrite_test.c2
-rw-r--r--test/core/json/json_stream_error_test.c2
-rw-r--r--test/core/json/json_test.c4
11 files changed, 51 insertions, 6 deletions
diff --git a/test/core/json/corpus/15a8f2e7f94aa00b46f1b991416aa015dd633580 b/test/core/json/corpus/15a8f2e7f94aa00b46f1b991416aa015dd633580
new file mode 100644
index 0000000000..7e613e891d
--- /dev/null
+++ b/test/core/json/corpus/15a8f2e7f94aa00b46f1b991416aa015dd633580
@@ -0,0 +1 @@
+{"":21} \ No newline at end of file
diff --git a/test/core/json/corpus/56cd60743c2cee939f5f357905bd36ec9363f441 b/test/core/json/corpus/56cd60743c2cee939f5f357905bd36ec9363f441
new file mode 100644
index 0000000000..8d53a05e08
--- /dev/null
+++ b/test/core/json/corpus/56cd60743c2cee939f5f357905bd36ec9363f441
@@ -0,0 +1 @@
+{"":21] \ No newline at end of file
diff --git a/test/core/json/corpus/743e89b768af4bd591ea7228118550b1bfb8e7d1 b/test/core/json/corpus/743e89b768af4bd591ea7228118550b1bfb8e7d1
new file mode 100644
index 0000000000..b232065b09
--- /dev/null
+++ b/test/core/json/corpus/743e89b768af4bd591ea7228118550b1bfb8e7d1
@@ -0,0 +1 @@
+{"":0}f'+G{)13(§!(''\! \ No newline at end of file
diff --git a/test/core/json/corpus/775e8ffda1f5d340dba472d06dc7c8bf8159e379 b/test/core/json/corpus/775e8ffda1f5d340dba472d06dc7c8bf8159e379
new file mode 100644
index 0000000000..6f56d403bb
--- /dev/null
+++ b/test/core/json/corpus/775e8ffda1f5d340dba472d06dc7c8bf8159e379
@@ -0,0 +1 @@
+{"":0},f'+G{)23(§!''! \ No newline at end of file
diff --git a/test/core/json/corpus/8d952ec2e33b2a6a1c7876898719a610f5546388 b/test/core/json/corpus/8d952ec2e33b2a6a1c7876898719a610f5546388
new file mode 100644
index 0000000000..fb7475be91
--- /dev/null
+++ b/test/core/json/corpus/8d952ec2e33b2a6a1c7876898719a610f5546388
@@ -0,0 +1 @@
+{"":0]f'+G{)13(§!(''\! \ No newline at end of file
diff --git a/test/core/json/corpus/a0d4af29c6c223b48fe34d6a09b3a7466242f33c b/test/core/json/corpus/a0d4af29c6c223b48fe34d6a09b3a7466242f33c
new file mode 100644
index 0000000000..db616e9f56
--- /dev/null
+++ b/test/core/json/corpus/a0d4af29c6c223b48fe34d6a09b3a7466242f33c
@@ -0,0 +1 @@
+{"":0],f'`+G{-22(§!''! \ No newline at end of file
diff --git a/test/core/json/fuzzer.c b/test/core/json/fuzzer.c
index 65f89e64a4..044db973ab 100644
--- a/test/core/json/fuzzer.c
+++ b/test/core/json/fuzzer.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015-2016, Google Inc.
+ * Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -35,16 +35,53 @@
#include <string.h>
#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
#include "src/core/lib/json/json.h"
+static size_t g_total_size = 0;
+static gpr_allocation_functions g_old_allocs;
+
+void *guard_malloc(size_t size) {
+ size_t *ptr;
+ g_total_size += size;
+ ptr = g_old_allocs.malloc_fn(size + sizeof(size));
+ *ptr++ = size;
+ return ptr;
+}
+
+void *guard_realloc(void *vptr, size_t size) {
+ size_t *ptr = vptr;
+ --ptr;
+ g_total_size -= *ptr;
+ ptr = g_old_allocs.realloc_fn(ptr, size + sizeof(size));
+ g_total_size += size;
+ *ptr++ = size;
+ return ptr;
+}
+
+void guard_free(void *vptr) {
+ size_t *ptr = vptr;
+ --ptr;
+ g_total_size -= *ptr;
+ g_old_allocs.free_fn(ptr);
+}
+
+struct gpr_allocation_functions g_guard_allocs = {guard_malloc, guard_realloc,
+ guard_free};
+
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
- char *s = gpr_malloc(size);
+ char *s;
+ g_old_allocs = gpr_get_allocation_functions();
+ gpr_set_allocation_functions(g_guard_allocs);
+ s = gpr_malloc(size);
memcpy(s, data, size);
grpc_json *x;
if ((x = grpc_json_parse_string_with_len(s, size))) {
grpc_json_destroy(x);
}
gpr_free(s);
+ gpr_set_allocation_functions(g_old_allocs);
+ GPR_ASSERT(g_total_size == 0);
return 0;
}
diff --git a/test/core/json/json_rewrite.c b/test/core/json/json_rewrite.c
index 41090db105..c43c6e2589 100644
--- a/test/core/json/json_rewrite.c
+++ b/test/core/json/json_rewrite.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015-2016, Google Inc.
+ * Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/test/core/json/json_rewrite_test.c b/test/core/json/json_rewrite_test.c
index 33fc98ed74..cf42670337 100644
--- a/test/core/json/json_rewrite_test.c
+++ b/test/core/json/json_rewrite_test.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015-2016, Google Inc.
+ * Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/test/core/json/json_stream_error_test.c b/test/core/json/json_stream_error_test.c
index 630e1b03df..82b9bd96d3 100644
--- a/test/core/json/json_stream_error_test.c
+++ b/test/core/json/json_stream_error_test.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015-2016, Google Inc.
+ * Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/test/core/json/json_test.c b/test/core/json/json_test.c
index 13ee5bbe45..ac1abbd8f3 100644
--- a/test/core/json/json_test.c
+++ b/test/core/json/json_test.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015-2016, Google Inc.
+ * Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -89,6 +89,8 @@ static testing_pair testing_pairs[] = {
{"{\"foo\": bar}", NULL},
{"{\"foo\": bar\"x\"}", NULL},
{"fals", NULL},
+ {"0,0 ", NULL},
+ {"\"foo\",[]", NULL},
/* Testing unterminated string. */
{"\"\\x", NULL},
/* Testing invalid UTF-16 number. */