ct.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (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. * Fuzz the SCT parser.
  12. */
  13. #include <stdio.h>
  14. #include <openssl/ct.h>
  15. #include <openssl/err.h>
  16. #include "fuzzer.h"
  17. int FuzzerInitialize(int *argc, char ***argv)
  18. {
  19. OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
  20. CRYPTO_free_ex_index(0, -1);
  21. ERR_get_state();
  22. return 1;
  23. }
  24. int FuzzerTestOneInput(const uint8_t *buf, size_t len)
  25. {
  26. const uint8_t **pp = &buf;
  27. unsigned char *der = NULL;
  28. STACK_OF(SCT) *scts = d2i_SCT_LIST(NULL, pp, len);
  29. if (scts != NULL) {
  30. BIO *bio = BIO_new(BIO_s_null());
  31. SCT_LIST_print(scts, bio, 4, "\n", NULL);
  32. BIO_free(bio);
  33. if (i2d_SCT_LIST(scts, &der)) {
  34. /* Silence unused result warning */
  35. }
  36. OPENSSL_free(der);
  37. SCT_LIST_free(scts);
  38. }
  39. ERR_clear_error();
  40. return 0;
  41. }
  42. void FuzzerCleanup(void)
  43. {
  44. }