mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-19 16:47:28 +01:00
Add base.token_decoder.workbuf_len
This commit is contained in:
1 parent
40d200cdab
commit
f3146c2ea9
11 files changed
+193
-52
No files matched your search
@@ -62,6 +62,17 @@ It should print "PASS", amongst other information, and exit(0).
|
||||
#define TOK_BUFFER_ARRAY_SIZE 4096
|
||||
#define STACK_SIZE (WUFFS_JSON__DECODER_DEPTH_MAX_INCL + 1)
|
||||
|
||||
// Wuffs allows either statically or dynamically allocated work buffers. This
|
||||
// program exercises static allocation.
|
||||
#define WORK_BUFFER_ARRAY_SIZE \
|
||||
WUFFS_JSON__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE
|
||||
#if WORK_BUFFER_ARRAY_SIZE > 0
|
||||
uint8_t work_buffer_array[WORK_BUFFER_ARRAY_SIZE];
|
||||
#else
|
||||
// Not all C/C++ compilers support 0-length arrays.
|
||||
uint8_t work_buffer_array[1];
|
||||
#endif
|
||||
|
||||
// Each stack element is 1 byte. The low 7 bits denote the container:
|
||||
// - 0x01 means no container: we are at the top level.
|
||||
// - 0x02 means a [] list.
|
||||
@@ -297,7 +308,9 @@ fuzz_complex(wuffs_base__io_buffer* full_src, uint32_t hash_24_bits) {
|
||||
size_t old_src_ri = src.meta.ri;
|
||||
size_t ti = old_src_ri;
|
||||
|
||||
status = wuffs_json__decoder__decode_tokens(&dec, &tok, &src);
|
||||
status = wuffs_json__decoder__decode_tokens(
|
||||
&dec, &tok, &src,
|
||||
wuffs_base__make_slice_u8(work_buffer_array, WORK_BUFFER_ARRAY_SIZE));
|
||||
if ((tok.data.len < tok.meta.wi) || //
|
||||
(tok.meta.wi < tok.meta.ri) || //
|
||||
(tok.meta.ri != old_tok_ri)) {
|
||||
@@ -386,7 +399,9 @@ fuzz_simple(wuffs_base__io_buffer* full_src) {
|
||||
});
|
||||
|
||||
while (true) {
|
||||
status = wuffs_json__decoder__decode_tokens(&dec, &tok, full_src);
|
||||
status = wuffs_json__decoder__decode_tokens(
|
||||
&dec, &tok, full_src,
|
||||
wuffs_base__make_slice_u8(work_buffer_array, WORK_BUFFER_ARRAY_SIZE));
|
||||
if (status.repr == NULL) {
|
||||
break;
|
||||
|
||||
|
||||
@@ -101,10 +101,7 @@ fuzz(wuffs_base__io_buffer* src, uint32_t hash) {
|
||||
dst.meta.wi = 0;
|
||||
status =
|
||||
wuffs_zlib__decoder__transform_io(&dec, &dst, src,
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = work_buffer_array,
|
||||
.len = WORK_BUFFER_ARRAY_SIZE,
|
||||
}));
|
||||
wuffs_base__make_slice_u8(work_buffer_array, WORK_BUFFER_ARRAY_SIZE));
|
||||
if (status.repr != wuffs_base__suspension__short_write) {
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user