fuzzing BUGFIX fuzz harnesses
Update lys_parse_mem and lyd_parse_mem fuzz harnesses to work with API
changes introduced in 7931b19.
diff --git a/tests/fuzz/lyd_parse_mem.c b/tests/fuzz/lyd_parse_mem.c
index 75cbc93..fb1ce13 100644
--- a/tests/fuzz/lyd_parse_mem.c
+++ b/tests/fuzz/lyd_parse_mem.c
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
+#include <string.h>
#include "libyang.h"
@@ -10,7 +11,7 @@
static bool log = false;
const char *schema_a = "module defs {namespace urn:tests:defs;prefix d;yang-version 1.1;"
"identity crypto-alg; identity interface-type; identity ethernet {base interface-type;} identity fast-ethernet {base ethernet;}}";
- const char *schema_b = "module types {namespace urn:tests:types;prefix t;yang-version 1.1; import defs {prefix defs;}"
+ const char *schema_b = "module types {namespace urn:tests:types;prefix t;yang-version 1.1; import defs {prefix defs;}"
"feature f; identity gigabit-ethernet { base defs:ethernet;}"
"container cont {leaf leaftarget {type empty;}"
"list listtarget {key id; max-elements 5;leaf id {type uint8;} leaf value {type string;}}"
@@ -49,6 +50,7 @@
"type union { type identityref {base defs:interface-type;} type instance-identifier {require-instance true;} }"
"type string {length 1..20;}}}}";
char *data = NULL;
+ struct lyd_node *tree = NULL;
LY_ERR err;
@@ -63,8 +65,8 @@
exit(EXIT_FAILURE);
}
- lys_parse_mem(ctx, schema_a, LYS_IN_YANG);
- lys_parse_mem(ctx, schema_b, LYS_IN_YANG);
+ lys_parse_mem(ctx, schema_a, LYS_IN_YANG, NULL);
+ lys_parse_mem(ctx, schema_b, LYS_IN_YANG, NULL);
data = malloc(len + 1);
if (data == NULL) {
@@ -73,7 +75,7 @@
memcpy(data, buf, len);
data[len] = 0;
- lyd_parse_mem(ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY);
+ lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree);
ly_ctx_destroy(ctx, NULL);
free(data);
diff --git a/tests/fuzz/lys_parse_mem.c b/tests/fuzz/lys_parse_mem.c
index 516a6d9..59884f3 100644
--- a/tests/fuzz/lys_parse_mem.c
+++ b/tests/fuzz/lys_parse_mem.c
@@ -30,7 +30,7 @@
memcpy(data, buf, len);
data[len] = 0;
- lys_parse_mem(ctx, data, LYS_IN_YANG);
+ lys_parse_mem(ctx, data, LYS_IN_YANG, NULL);
ly_ctx_destroy(ctx, NULL);
free(data);
return 0;