grpc
test
core
json
fuzzer.cc
Go to the documentation of this file.
1
/*
2
*
3
* Copyright 2015 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
#include <
stdint.h
>
21
#include <
string.h
>
22
23
#include <
grpc/support/alloc.h
>
24
#include <
grpc/support/log.h
>
25
26
#include "
src/core/lib/json/json.h
"
27
28
bool
squelch
=
true
;
29
bool
leak_check
=
true
;
30
31
extern
"C"
int
LLVMFuzzerTestOneInput
(
const
uint8_t
*
data
,
size_t
size
) {
32
grpc_error_handle
error
=
GRPC_ERROR_NONE
;
33
auto
json =
grpc_core::Json::Parse
(
34
absl::string_view
(
reinterpret_cast<
const
char
*
>
(
data
),
size
), &
error
);
35
if
(
GRPC_ERROR_IS_NONE
(
error
)) {
36
auto
text2 = json.Dump();
37
auto
json2 =
grpc_core::Json::Parse
(text2, &
error
);
38
GPR_ASSERT
(
GRPC_ERROR_IS_NONE
(
error
));
39
GPR_ASSERT
(json == json2);
40
}
41
GRPC_ERROR_UNREF
(
error
);
42
return
0;
43
}
GRPC_ERROR_NONE
#define GRPC_ERROR_NONE
Definition:
error.h:234
LLVMFuzzerTestOneInput
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
Definition:
fuzzer.cc:31
log.h
string.h
absl::string_view
Definition:
abseil-cpp/absl/strings/string_view.h:167
error
grpc_error_handle error
Definition:
retry_filter.cc:499
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
squelch
bool squelch
Definition:
fuzzer.cc:28
leak_check
bool leak_check
Definition:
fuzzer.cc:29
data
char data[kBufferLength]
Definition:
abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
json.h
stdint.h
grpc_core::Json::Parse
static Json Parse(absl::string_view json_str, grpc_error_handle *error)
Definition:
json_reader.cc:899
alloc.h
GRPC_ERROR_UNREF
#define GRPC_ERROR_UNREF(err)
Definition:
error.h:262
grpc_error
Definition:
error_internal.h:42
size
voidpf void uLong size
Definition:
bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
GRPC_ERROR_IS_NONE
#define GRPC_ERROR_IS_NONE(err)
Definition:
error.h:241
grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:25