Skip to content

eBPF-based security platform

proofs: emit an unsigned number in json-emit-nest

Daniel Borkmann38b9cf9f2d8e
diff --git a/Documentation/contribute/testing/proof-coverage.rst b/Documentation/contribute/testing/proof-coverage.rst
index 49d06649..8724a1d9 100644
--- a/Documentation/contribute/testing/proof-coverage.rst
+++ b/Documentation/contribute/testing/proof-coverage.rst
@@ -790,7 +790,8 @@ or shorter, and "lengths 0 to 6" every input of each of those lengths.
- Grows only up to its limit; fails exactly when the text does not
fit, keeping the longest prefix that does, terminated
* - ``json-emit-nest``
- - Every container and key writer
+ - Every container and key writer, ``json_kv_u64()`` and
+ ``json_u64_value()`` among them
- Every sequence of up to 4 calls, every depth
- Valid JSON by a byte-level recognizer; a comma only after a
member; ``-E2BIG`` past the deepest level
diff --git a/testing/proofs/cbmc/json-emit-nest.c b/testing/proofs/cbmc/json-emit-nest.c
index ee4c75db..5aa7dbca 100644
--- a/testing/proofs/cbmc/json-emit-nest.c
+++ b/testing/proofs/cbmc/json-emit-nest.c
@@ -147,7 +147,7 @@ static void push(bool *array, size_t *depth, bool is_array)
static void value(struct json_emit *e, __u8 op, bool *array, size_t *depth)
{
- switch (op % 5) {
+ switch (op % 6) {
case 0:
json_obj_value_open(e);
push(array, depth, false);
@@ -162,6 +162,9 @@ static void value(struct json_emit *e, __u8 op, bool *array, size_t *depth)
case 3:
json_raw_value(e, "-1", 2);
return;
+ case 4:
+ json_u64_value(e, 42);
+ return;
}
json_str_lossy(e, "\xff", 1);
}
@@ -187,7 +190,7 @@ static void element(struct json_emit *e, __u8 op, bool *array,
static void member(struct json_emit *e, __u8 op, bool *array, size_t *depth,
bool *pending)
{
- switch (op % 9) {
+ switch (op % 10) {
case 0:
json_obj_open_key(e, "o");
push(array, depth, false);
@@ -216,6 +219,9 @@ static void member(struct json_emit *e, __u8 op, bool *array, size_t *depth,
case 7:
json_kv_null(e, "n");
return;
+ case 8:
+ json_kv_u64(e, "u", 42);
+ return;
}
json_kv_raw(e, "r", "[]", 2);
}