/src/fuzz-targets/pem_cert/target.c
Line | Count | Source |
1 | | /* pem_cert.c |
2 | | * |
3 | | * Copyright (C) 2006-2017 wolfSSL Inc. |
4 | | * |
5 | | * This file is part of wolfSSL. |
6 | | * |
7 | | * wolfSSL is free software; you can redistribute it and/or modify |
8 | | * it under the terms of the GNU General Public License as published by |
9 | | * the Free Software Foundation; either version 2 of the License, or |
10 | | * (at your option) any later version. |
11 | | * |
12 | | * wolfSSL is distributed in the hope that it will be useful, |
13 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | | * GNU General Public License for more details. |
16 | | * |
17 | | * You should have received a copy of the GNU General Public License |
18 | | * along with this program; if not, write to the Free Software |
19 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA |
20 | | */ |
21 | | |
22 | | #include <stdlib.h> |
23 | | #include <stdint.h> |
24 | | |
25 | | #include <wolfssl/options.h> |
26 | | #include <wolfssl/ssl.h> |
27 | | |
28 | 7.59k | #define WC_MAX_FUZZ_INPUT_SZ 25000 |
29 | | |
30 | | /* testing wolfSSL_CTX_use_certificate_buffer with PEM as the filetype*/ |
31 | | |
32 | | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t sz) |
33 | 7.59k | { |
34 | 7.59k | WOLFSSL_CTX *ctx; |
35 | 7.59k | int ret; |
36 | | |
37 | | /* avoid 25s timeout with parsing large files */ |
38 | 7.59k | if (sz > WC_MAX_FUZZ_INPUT_SZ) { |
39 | 3 | return 0; |
40 | 3 | } |
41 | | |
42 | 7.59k | wolfSSL_Init(); |
43 | | |
44 | 7.59k | ctx = wolfSSL_CTX_new(wolfTLSv1_2_server_method()); |
45 | | |
46 | 7.59k | wolfSSL_CTX_load_verify_buffer(ctx, data, sz, SSL_FILETYPE_PEM); |
47 | | |
48 | 7.59k | wolfSSL_CTX_free(ctx); |
49 | 7.59k | wolfSSL_Cleanup(); |
50 | 7.59k | return 0; |
51 | 7.59k | } |