fuzzing REFACTOR fuzz harneses (#1126)
Fix minor issues with implicit function declarations, terminate fuzzer
string inputs with string termination characters and add an XML parser
harness
diff --git a/tests/fuzz/lys_parse_mem.c b/tests/fuzz/lys_parse_mem.c
index 6ab5e0b..516a6d9 100644
--- a/tests/fuzz/lys_parse_mem.c
+++ b/tests/fuzz/lys_parse_mem.c
@@ -8,6 +8,7 @@
{
struct ly_ctx *ctx = NULL;
static bool log = false;
+ char *data = NULL;
LY_ERR err;
if (!log) {
@@ -21,7 +22,16 @@
exit(EXIT_FAILURE);
}
- lys_parse_mem(ctx, buf, LYS_IN_YANG);
+ data = malloc(len + 1);
+ if (data == NULL) {
+ return 0;
+ }
+
+ memcpy(data, buf, len);
+ data[len] = 0;
+
+ lys_parse_mem(ctx, data, LYS_IN_YANG);
ly_ctx_destroy(ctx, NULL);
+ free(data);
return 0;
}