session.cc
Go to the documentation of this file.
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 
15 #include <stdio.h>
16 
17 #include <openssl/mem.h>
18 #include <openssl/ssl.h>
19 
20 struct GlobalState {
22 
23  bssl::UniquePtr<SSL_CTX> ctx;
24 };
25 
27 
28 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
29  // Parse in our session.
30  bssl::UniquePtr<SSL_SESSION> session(
32 
33  // If the format was invalid, just return.
34  if (!session) {
35  return 0;
36  }
37 
38  // Stress the encoder.
39  size_t encoded_len;
40  uint8_t *encoded;
41  if (!SSL_SESSION_to_bytes(session.get(), &encoded, &encoded_len)) {
42  fprintf(stderr, "SSL_SESSION_to_bytes failed.\n");
43  return 1;
44  }
45 
46  OPENSSL_free(encoded);
47  return 0;
48 }
ctx
Definition: benchmark-async.c:30
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
SSL_SESSION_from_bytes
#define SSL_SESSION_from_bytes
Definition: boringssl_prefix_symbols.h:242
GlobalState
Definition: session.cc:20
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
python_utils.port_server.stderr
stderr
Definition: port_server.py:51
SSL_CTX_new
#define SSL_CTX_new
Definition: boringssl_prefix_symbols.h:115
SSL_SESSION_to_bytes
#define SSL_SESSION_to_bytes
Definition: boringssl_prefix_symbols.h:272
ssl.h
TLS_method
#define TLS_method
Definition: boringssl_prefix_symbols.h:538
LLVMFuzzerTestOneInput
int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len)
Definition: session.cc:28
g_state
static GlobalState g_state
Definition: session.cc:26
mem.h
len
int len
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:46
GlobalState::ctx
bssl::UniquePtr< SSL_CTX > ctx
Definition: session.cc:23
OPENSSL_free
#define OPENSSL_free
Definition: boringssl_prefix_symbols.h:1869
GlobalState::GlobalState
GlobalState()
Definition: session.cc:21


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:18