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