forked from tarantool/tarantool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test/fuzz: add fuzzing test for xrow_decode_error
The patch adds a fuzzing test for IPROTO decoding function xrow_decode_error(). Follows up tarantool#8921 Follows up tarantool#9098 NO_DOC=testing NO_CHANGELOG=testing
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include "box/xrow.h" | ||
#include "box/iproto_constants.h" | ||
#include "memory.h" | ||
|
||
void | ||
cord_on_yield(void) {} | ||
|
||
__attribute__((constructor)) | ||
static void | ||
setup(void) | ||
{ | ||
memory_init(); | ||
} | ||
|
||
__attribute__((destructor)) | ||
static void | ||
teardown(void) | ||
{ | ||
memory_free(); | ||
} | ||
|
||
int | ||
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) | ||
{ | ||
const char *d = (const char *)data; | ||
const char *end = (const char *)data + size; | ||
if (mp_check(&d, end) != 0) | ||
return -1; | ||
|
||
struct iovec body = {0}; | ||
body.iov_base = (void *)data; | ||
body.iov_len = size; | ||
|
||
struct xrow_header row = {0}; | ||
row.body[0] = body; | ||
row.bodycnt = 1; | ||
|
||
xrow_decode_error(&row); | ||
|
||
diag_destroy(diag_get()); | ||
assert(diag_is_empty(diag_get()) == true); | ||
|
||
return 0; | ||
} |