1 /* 2 * JSON parser - test program 3 * Copyright (c) 2019, Jouni Malinen <j@w1.fi> 4 * 5 * This software may be distributed under the terms of the BSD license. 6 * See README for more details. 7 */ 8 9 #include "utils/includes.h" 10 #include "utils/common.h" 11 #include "utils/json.h" 12 #include "../fuzzer-common.h" 13 14 LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)15int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) 16 { 17 struct json_token *root; 18 char *txt; 19 size_t buflen = 10000; 20 21 wpa_fuzzer_set_debug_level(); 22 23 root = json_parse((const char *) data, size); 24 if (!root) { 25 wpa_printf(MSG_DEBUG, "JSON parsing failed"); 26 return 0; 27 } 28 29 txt = os_zalloc(buflen); 30 if (txt) { 31 json_print_tree(root, txt, buflen); 32 wpa_printf(MSG_DEBUG, "%s", txt); 33 os_free(txt); 34 } 35 json_free(root); 36 37 return 0; 38 } 39