blob: 87fe857099b8482beaab2eafbb2d6c28c24a2651 [file] [log] [blame]
Ben Lauriec38bb722016-03-26 17:19:14 +00001/*
2 * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the OpenSSL licenses, (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>
Kurt Roeckxd69d8f92016-12-02 19:34:54 +010016#include <openssl/err.h>
Ben Lauriec38bb722016-03-26 17:19:14 +000017#include "fuzzer.h"
18
Kurt Roeckxf3e911d2016-11-19 17:10:35 +010019int FuzzerInitialize(int *argc, char ***argv)
20{
Kurt Roeckxd69d8f92016-12-02 19:34:54 +010021 OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
22 ERR_get_state();
Ben Laurie90d28f02016-06-04 16:10:49 +010023 return 1;
24}
25
Kurt Roeckxf3e911d2016-11-19 17:10:35 +010026int FuzzerTestOneInput(const uint8_t *buf, size_t len)
27{
Kurt Roeckxea6199e2016-11-02 20:45:46 +010028 CONF *conf;
29 BIO *in;
Ben Lauriec38bb722016-03-26 17:19:14 +000030 long eline;
31
Kurt Roeckxea6199e2016-11-02 20:45:46 +010032 if (len == 0)
33 return 0;
34
35 conf = NCONF_new(NULL);
36 in = BIO_new(BIO_s_mem());
Ben Lauriec38bb722016-03-26 17:19:14 +000037 OPENSSL_assert((size_t)BIO_write(in, buf, len) == len);
38 NCONF_load_bio(conf, in, &eline);
Ben Lauriec38bb722016-03-26 17:19:14 +000039 NCONF_free(conf);
40 BIO_free(in);
Kurt Roeckxd69d8f92016-12-02 19:34:54 +010041 ERR_clear_error();
Ben Lauriec38bb722016-03-26 17:19:14 +000042
43 return 0;
44}
Kurt Roeckxad4da7f2016-11-19 17:13:10 +010045
46void FuzzerCleanup(void)
47{
48}