您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* Copyright (c) 2016, Google Inc.
  2. *
  3. * Permission to use, copy, modify, and/or distribute this software for any
  4. * purpose with or without fee is hereby granted, provided that the above
  5. * copyright notice and this permission notice appear in all copies.
  6. *
  7. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  8. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  9. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  10. * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  12. * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  13. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
  14. #include <stdio.h>
  15. #include <openssl/mem.h>
  16. #include <openssl/ssl.h>
  17. extern "C" int LLVMFuzzerTestOneInput(uint8_t *buf, size_t len) {
  18. // Parse in our session.
  19. bssl::UniquePtr<SSL_SESSION> session(SSL_SESSION_from_bytes(buf, len));
  20. // If the format was invalid, just return.
  21. if (!session) {
  22. return 0;
  23. }
  24. // Stress the encoder.
  25. size_t encoded_len;
  26. uint8_t *encoded;
  27. if (!SSL_SESSION_to_bytes(session.get(), &encoded, &encoded_len)) {
  28. fprintf(stderr, "SSL_SESSION_to_bytes failed.\n");
  29. return 1;
  30. }
  31. OPENSSL_free(encoded);
  32. return 0;
  33. }