diff options
author | Hardik Shah <hardik05@gmail.com> | 2023-02-13 08:19:23 +0530 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2023-03-01 20:25:15 +1100 |
commit | 55aab29c1ea2b8103aa0f0ecb20c058ff200fe27 (patch) | |
tree | 462c175e8721fc0d64a6b8832ac561e41d7df3f1 /fuzz/v3name.c | |
parent | 1735531c8ba7542e5fb2fe2f0becddb595955ace (diff) |
Add fuzz test for v3name
v3name_fuzzer build modifications
create 99-test_fuzz_v3name_fuzzer.t
test corpus for cve-2023-0286
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20274)
Diffstat (limited to 'fuzz/v3name.c')
-rw-r--r-- | fuzz/v3name.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/fuzz/v3name.c b/fuzz/v3name.c new file mode 100644 index 0000000000..2c7f94e17f --- /dev/null +++ b/fuzz/v3name.c @@ -0,0 +1,44 @@ +/* + * Copyright 2012-2023 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include <string.h> +#include <openssl/e_os2.h> +#include <openssl/x509.h> +#include <openssl/x509v3.h> +#include "internal/nelem.h" +#include "fuzzer.h" + +int FuzzerInitialize(int *argc, char ***argv) +{ + return 1; +} + +int FuzzerTestOneInput(const uint8_t* data, size_t size){ + GENERAL_NAME *namesa; + GENERAL_NAME *namesb; + + const unsigned char *derp = data; + /* + * We create two versions of each GENERAL_NAME so that we ensure when + * we compare them they are always different pointers. + */ + namesa = d2i_GENERAL_NAME(NULL, &derp, size); + derp = data; + namesb = d2i_GENERAL_NAME(NULL, &derp, size); + GENERAL_NAME_cmp(namesa, namesb); + if (namesa != NULL) + GENERAL_NAME_free(namesa); + if (namesb != NULL) + GENERAL_NAME_free(namesb); + return 0; +} + +void FuzzerCleanup(void) +{ +} |