/src/rnp/src/fuzzing/dump.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2020, [Ribose Inc](https://www.ribose.com). |
3 | | * All rights reserved. |
4 | | * |
5 | | * Redistribution and use in source and binary forms, with or without modification, |
6 | | * are permitted provided that the following conditions are met: |
7 | | * |
8 | | * 1. Redistributions of source code must retain the above copyright notice, |
9 | | * this list of conditions and the following disclaimer. |
10 | | * |
11 | | * 2. Redistributions in binary form must reproduce the above copyright notice, |
12 | | * this list of conditions and the following disclaimer in the documentation |
13 | | * and/or other materials provided with the distribution. |
14 | | * |
15 | | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
16 | | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
17 | | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
18 | | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE |
19 | | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
20 | | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
21 | | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
22 | | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
23 | | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
24 | | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 | | */ |
26 | | |
27 | | #include <rnp/rnp.h> |
28 | | |
29 | | #ifdef RNP_RUN_TESTS |
30 | | int dump_LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); |
31 | | int |
32 | | dump_LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) |
33 | | #else |
34 | | int |
35 | | LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) |
36 | | #endif |
37 | 53.4k | { |
38 | 53.4k | rnp_input_t input = NULL; |
39 | 53.4k | (void) rnp_input_from_memory(&input, data, size, false); |
40 | 53.4k | rnp_output_t output = NULL; |
41 | 53.4k | (void) rnp_output_to_null(&output); |
42 | | |
43 | 53.4k | (void) rnp_dump_packets_to_output(input, output, RNP_DUMP_RAW); |
44 | 53.4k | rnp_output_destroy(output); |
45 | 53.4k | rnp_input_destroy(input); |
46 | | |
47 | 53.4k | rnp_input_t input2 = NULL; |
48 | 53.4k | (void) rnp_input_from_memory(&input2, data, size, false); |
49 | 53.4k | char *json = NULL; |
50 | 53.4k | (void) rnp_dump_packets_to_json(input2, RNP_DUMP_RAW, &json); |
51 | 53.4k | rnp_buffer_destroy(json); |
52 | 53.4k | rnp_input_destroy(input2); |
53 | | |
54 | 53.4k | return 0; |
55 | 53.4k | } |