mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 00:32:11 +01:00
Add fuzz/c/std/json_fuzzer.c
This commit is contained in:
1 parent
6b29f32564
commit
21682f403f
6 files changed
+375
-2
No files matched your search
@@ -21,6 +21,27 @@ pub status "#unsupported recursion depth"
|
||||
|
||||
pri status "#internal error: inconsistent I/O"
|
||||
|
||||
// decoder_depth_max_incl is the maximum supported recursion depth: how deeply
|
||||
// nested [] arrays and {} objects can be.
|
||||
//
|
||||
// The JSON spec itself does not define a limit, but allows implementations to
|
||||
// set their own limits.
|
||||
pub const decoder_depth_max_incl base.u64 = 1024
|
||||
|
||||
// decoder_dst_token_buffer_length_min_incl is the minimum length of the dst
|
||||
// wuffs_base__token_buffer passed to the decoder.
|
||||
pub const decoder_dst_token_buffer_length_min_incl base.u64 = 1
|
||||
|
||||
// decoder_src_io_buffer_length_min_incl is the minimum length of the src
|
||||
// wuffs_base__io_buffer passed to the decoder.
|
||||
//
|
||||
// This constrains the src.data.len field and it is the io_buffer capacity (the
|
||||
// maximum possible src.meta.ri and src.meta.wi values). It is a property of
|
||||
// the backing array's length, not the length of the JSON-formatted input per
|
||||
// se. It is perfectly valid to decode "[1,2]" (of length 5) as JSON, as long
|
||||
// as that content is placed in an io_buffer whose data.len is at least 100.
|
||||
pub const decoder_src_io_buffer_length_min_incl base.u64 = 100
|
||||
|
||||
// Look-Up Tables (LUTs).
|
||||
|
||||
pri const lut_backslashes array[256] base.u8 = [
|
||||
|
||||
@@ -30,7 +30,8 @@ pub struct decoder? implements base.token_decoder(
|
||||
//
|
||||
// Wuffs code does not have the capability to dynamically allocate memory,
|
||||
// so the maximum depth is hard-coded at compile time. In this case, the
|
||||
// maximum is 1024 (stack is 1024 bits or 128 bytes).
|
||||
// maximum is 1024 (stack is 1024 bits or 128 bytes), also known as
|
||||
// decoder_depth_max_incl.
|
||||
//
|
||||
// The [JSON spec](https://tools.ietf.org/html/rfc7159) clearly states, "an
|
||||
// implementation may set limits on the maximum depth of nesting".
|
||||
@@ -926,7 +927,8 @@ pri func decoder.decode_digits!(src: base.io_reader, n: base.u32[..= 0xFF]) base
|
||||
break
|
||||
}
|
||||
// Cap the maximum supported number length at an arbitrary value, 99.
|
||||
// The caller's src.data.len should therefore be at least 100.
|
||||
// The caller's src.data.len should therefore be at least 100, also
|
||||
// known as decoder_src_io_buffer_length_min_incl.
|
||||
//
|
||||
// An example of a JSON number that is 81 bytes long is:
|
||||
// https://github.com/nst/JSONTestSuite/blob/master/test_parsing/y_number_double_close_to_zero.json
|
||||
|
||||
Reference in new issue
Block a user