/*1* Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.2*3* Licensed under the Apache License 2.0 (the "License");4* you may not use this file except in compliance with the License.5* You may obtain a copy of the License at6* https://www.openssl.org/source/license.html7* or in the file LICENSE in the source distribution.8*/910/*11* Fuzz the parser used for dumping ASN.1 using "openssl asn1parse".12*/1314#include <stdio.h>15#include <openssl/asn1.h>16#include <openssl/x509.h>17#include <openssl/x509v3.h>18#include <openssl/err.h>19#include "fuzzer.h"2021static BIO *bio_out;2223int FuzzerInitialize(int *argc, char ***argv)24{25bio_out = BIO_new(BIO_s_null()); /* output will be ignored */26if (bio_out == NULL)27return 0;28OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);29ERR_clear_error();30CRYPTO_free_ex_index(0, -1);31return 1;32}3334int FuzzerTestOneInput(const uint8_t *buf, size_t len)35{36(void)ASN1_parse_dump(bio_out, buf, len, 0, 0);37ERR_clear_error();38return 0;39}4041void FuzzerCleanup(void)42{43BIO_free(bio_out);44}454647