grpc
test
core
util
one_corpus_entry_fuzzer.cc
Go to the documentation of this file.
1
/*
2
*
3
* Copyright 2016 gRPC authors.
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*
17
*/
18
19
#include <stdbool.h>
20
21
#include <
grpc/grpc.h
>
22
#include <
grpc/support/log.h
>
23
24
#include "
src/core/lib/iomgr/exec_ctx.h
"
25
#include "
src/core/lib/iomgr/load_file.h
"
26
27
extern
"C"
int
LLVMFuzzerTestOneInput
(
const
uint8_t
*
data
,
size_t
size
);
28
29
extern
bool
squelch
;
30
extern
bool
leak_check
;
31
32
int
main
(
int
argc,
char
** argv) {
33
grpc_slice
buffer
;
34
squelch
=
false
;
35
leak_check
=
false
;
36
/* TODO(yashkt) Calling grpc_init breaks tests. Fix the tests and replace
37
* grpc_core::ExecCtx::GlobalInit with grpc_init and GlobalShutdown with
38
* grpc_shutdown */
39
GPR_ASSERT
(argc > 1);
/* Make sure that we have a filename argument */
40
GPR_ASSERT
(
41
GRPC_LOG_IF_ERROR
(
"load_file"
,
grpc_load_file
(argv[1], 0, &
buffer
)));
42
LLVMFuzzerTestOneInput
(
GRPC_SLICE_START_PTR
(
buffer
),
43
GRPC_SLICE_LENGTH
(
buffer
));
44
grpc_core::ExecCtx::GlobalInit();
45
grpc_slice_unref
(
buffer
);
46
grpc_core::ExecCtx::GlobalShutdown();
47
return
0;
48
}
grpc_slice_unref
GPRAPI void grpc_slice_unref(grpc_slice s)
Definition:
slice_api.cc:32
log.h
grpc_load_file
grpc_error_handle grpc_load_file(const char *filename, int add_null_terminator, grpc_slice *output)
Definition:
load_file.cc:33
load_file.h
LLVMFuzzerTestOneInput
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
Definition:
sockaddr_utils_fuzzer_test.cc:29
GRPC_LOG_IF_ERROR
#define GRPC_LOG_IF_ERROR(what, error)
Definition:
error.h:398
leak_check
bool leak_check
Definition:
avl_fuzzer.cc:20
uint8_t
unsigned char uint8_t
Definition:
stdint-msvc2008.h:78
GPR_ASSERT
#define GPR_ASSERT(x)
Definition:
include/grpc/impl/codegen/log.h:94
grpc.h
GRPC_SLICE_START_PTR
#define GRPC_SLICE_START_PTR(slice)
Definition:
include/grpc/impl/codegen/slice.h:101
grpc_slice
Definition:
include/grpc/impl/codegen/slice.h:65
data
char data[kBufferLength]
Definition:
abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
buffer
char buffer[1024]
Definition:
libuv/docs/code/idle-compute/main.c:8
GRPC_SLICE_LENGTH
#define GRPC_SLICE_LENGTH(slice)
Definition:
include/grpc/impl/codegen/slice.h:104
squelch
bool squelch
Definition:
sockaddr_utils_fuzzer_test.cc:27
exec_ctx.h
size
voidpf void uLong size
Definition:
bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
main
int main(int argc, char **argv)
Definition:
one_corpus_entry_fuzzer.cc:32
grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:35