xref: /src/crypto/openssl/fuzz/v3name.c (revision f25b8c9fb4f58cf61adb47d7570abe7caa6d385d)
1 /*
2  * Copyright 2012-2023 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License 2.0 (the "License").  You may not use
5  * this file except in compliance with the License.  You can obtain a copy
6  * in the file LICENSE in the source distribution or at
7  * https://www.openssl.org/source/license.html
8  */
9 
10 #include <string.h>
11 #include <openssl/e_os2.h>
12 #include <openssl/x509.h>
13 #include <openssl/x509v3.h>
14 #include "internal/nelem.h"
15 #include "fuzzer.h"
16 
FuzzerInitialize(int * argc,char *** argv)17 int FuzzerInitialize(int *argc, char ***argv)
18 {
19     return 1;
20 }
21 
FuzzerTestOneInput(const uint8_t * data,size_t size)22 int FuzzerTestOneInput(const uint8_t *data, size_t size)
23 {
24     GENERAL_NAME *namesa;
25     GENERAL_NAME *namesb;
26 
27     const unsigned char *derp = data;
28     /*
29      * We create two versions of each GENERAL_NAME so that we ensure when
30      * we compare them they are always different pointers.
31      */
32     namesa = d2i_GENERAL_NAME(NULL, &derp, size);
33     derp = data;
34     namesb = d2i_GENERAL_NAME(NULL, &derp, size);
35     GENERAL_NAME_cmp(namesa, namesb);
36     if (namesa != NULL)
37         GENERAL_NAME_free(namesa);
38     if (namesb != NULL)
39         GENERAL_NAME_free(namesb);
40     return 0;
41 }
42 
FuzzerCleanup(void)43 void FuzzerCleanup(void)
44 {
45 }
46