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