mirror of
https://github.com/json-c/json-c.git
synced 2026-11-07 14:10:17 +08:00
reject empty reference token as array index in json_pointer
This commit is contained in:
1 parent
1e39345938
commit
70f3169bae
3 files changed
+15
No files matched your search
@@ -203,6 +203,10 @@ static void test_wrong_inputs_get(void)
|
||||
assert(0 != json_pointer_get(jo1, "/foo/01", NULL));
|
||||
assert(errno == EINVAL);
|
||||
errno = 0;
|
||||
/* An empty reference token is not a valid array index */
|
||||
assert(0 != json_pointer_get(jo1, "/foo/", NULL));
|
||||
assert(errno == EINVAL);
|
||||
errno = 0;
|
||||
assert(0 != json_pointer_getf(jo1, NULL, "/%s/a", "foo"));
|
||||
assert(errno == EINVAL);
|
||||
errno = 0;
|
||||
@@ -314,6 +318,10 @@ static void test_wrong_inputs_set(void)
|
||||
printf("PASSED - SET - failed with invalid array index'\n");
|
||||
json_object_put(jo2);
|
||||
|
||||
assert(0 != json_pointer_set(&jo1, "/foo/", (jo2 = json_object_new_string("cod"))));
|
||||
printf("PASSED - SET - failed with empty array index'\n");
|
||||
json_object_put(jo2);
|
||||
|
||||
jo2 = json_object_new_string("whatever");
|
||||
assert(0 != json_pointer_set(&jo1, "/fud/gaw", jo2));
|
||||
assert(0 == json_pointer_set(&jo1, "/fud", json_object_new_object()));
|
||||
|
||||
Reference in new issue
Block a user