/src/openssl41/fuzz/conf.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright 2016-2026 The OpenSSL Project Authors. All Rights Reserved. |
3 | | * |
4 | | * Licensed under the Apache License 2.0 (the "License"); |
5 | | * you may not use this file except in compliance with the License. |
6 | | * You may obtain a copy of the License at |
7 | | * https://www.openssl.org/source/license.html |
8 | | * or in the file LICENSE in the source distribution. |
9 | | */ |
10 | | |
11 | | /* |
12 | | * Test configuration parsing. |
13 | | */ |
14 | | |
15 | | #include <openssl/conf.h> |
16 | | #include <openssl/err.h> |
17 | | #include "fuzzer.h" |
18 | | |
19 | | int FuzzerInitialize(int *argc, char ***argv) |
20 | 229 | { |
21 | 229 | OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL); |
22 | 229 | ERR_clear_error(); |
23 | 229 | return 1; |
24 | 229 | } |
25 | | |
26 | | int FuzzerTestOneInput(const uint8_t *buf, size_t len) |
27 | 3.06k | { |
28 | 3.06k | CONF *conf; |
29 | 3.06k | BIO *in; |
30 | 3.06k | long eline; |
31 | | |
32 | 3.06k | if (len == 0 || len > INT_MAX) |
33 | 0 | return 0; |
34 | | |
35 | 3.06k | conf = NCONF_new(NULL); |
36 | 3.06k | if (conf == NULL) |
37 | 0 | return 0; |
38 | 3.06k | in = BIO_new(BIO_s_mem()); |
39 | 3.06k | if (in == NULL) |
40 | 0 | goto end; |
41 | 3.06k | if ((size_t)BIO_write(in, buf, (int)len) != len) |
42 | 0 | goto end; |
43 | 3.06k | NCONF_load_bio(conf, in, &eline); |
44 | 3.06k | end: |
45 | 3.06k | NCONF_free(conf); |
46 | 3.06k | BIO_free(in); |
47 | 3.06k | ERR_clear_error(); |
48 | | |
49 | 3.06k | return 0; |
50 | 3.06k | } |
51 | | |
52 | | void FuzzerCleanup(void) |
53 | 0 | { |
54 | 0 | } |