/src/libtasn1/fuzz/asn1_get_length_ber_fuzzer.c
Line  | Count  | Source  | 
1  |  | /*  | 
2  |  |  * Copyright(c) 2020 Free Software Foundation, Inc.  | 
3  |  |  *  | 
4  |  |  * This file is part of libtasn1.  | 
5  |  |  *  | 
6  |  |  * Libtasn1 is free software: you can redistribute it and/or modify  | 
7  |  |  * it under the terms of the GNU Lesser General Public License as published by  | 
8  |  |  * the Free Software Foundation, either version 3 of the License, or  | 
9  |  |  * (at your option) any later version.  | 
10  |  |  *  | 
11  |  |  * Libtasn1 is distributed in the hope that it will be useful,  | 
12  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of  | 
13  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  | 
14  |  |  * GNU Lesser General Public License for more details.  | 
15  |  |  *  | 
16  |  |  * You should have received a copy of the GNU Lesser General Public License  | 
17  |  |  * along with libtasn1.  If not, see <https://www.gnu.org/licenses/>.  | 
18  |  |  *  | 
19  |  |  * This fuzzer is testing asn1_get_length_ber()'s robustness with arbitrary  | 
20  |  |  * input data.  | 
21  |  |  */  | 
22  |  |  | 
23  |  | #include <config.h>  | 
24  |  |  | 
25  |  | #include "libtasn1.h"  | 
26  |  | #include "fuzzer.h"  | 
27  |  |  | 
28  | 634  | #define MAXDATASIZE 512  | 
29  |  |  | 
30  |  | int  | 
31  |  | LLVMFuzzerTestOneInput (const uint8_t *data, size_t size)  | 
32  | 634  | { | 
33  | 634  |   int ret_len;  | 
34  |  |  | 
35  | 634  |   if (size > MAXDATASIZE)  /* same as max_len = <MAXDATASIZE> in .options file */  | 
36  | 26  |     return 0;  | 
37  |  |  | 
38  | 608  |   asn1_get_length_ber (data, size, &ret_len);  | 
39  |  |  | 
40  | 608  |   return 0;  | 
41  | 634  | }  |