Juraj Vijtiuk | 260407e | 2020-03-18 10:32:13 +0100 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | #include <stdbool.h> |
| 4 | |
| 5 | #include "libyang.h" |
| 6 | |
| 7 | int LLVMFuzzerTestOneInput(uint8_t const *buf, size_t len) |
| 8 | { |
| 9 | struct ly_ctx *ctx = NULL; |
| 10 | static bool log = false; |
| 11 | LY_ERR err; |
| 12 | |
| 13 | if (!log) { |
| 14 | ly_log_options(0); |
| 15 | log = true; |
| 16 | } |
| 17 | |
| 18 | err = ly_ctx_new(NULL, 0, &ctx); |
| 19 | if (err != LY_SUCCESS) { |
| 20 | fprintf(stderr, "Failed to create context\n"); |
| 21 | exit(EXIT_FAILURE); |
| 22 | } |
| 23 | |
| 24 | lys_parse_mem(ctx, buf, LYS_IN_YANG); |
| 25 | ly_ctx_destroy(ctx, NULL); |
| 26 | return 0; |
| 27 | } |