sockaddr_utils_fuzzer_test.cc
Go to the documentation of this file.
1 //
2 // Copyright 2022 gRPC authors.
3 //
4 // Licensed under the Apache License, Version 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 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 #include <stdbool.h>
18 #include <stdint.h>
19 #include <string.h>
20 
21 #include <grpc/grpc.h>
22 
26 
27 bool squelch = true;
28 
29 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
30  if (size > GRPC_MAX_SOCKADDR_SIZE) return 0;
31  grpc_resolved_address address;
32  memset(&address, 0, sizeof(address));
33  memcpy(address.addr, data, size);
34  address.len = size;
35 
37  if (!uri.ok()) return 0;
40 
41  GPR_ASSERT(parsed_uri.ok());
42  return 0;
43 }
sockaddr_utils.h
memset
return memset(p, 0, total)
string.h
resolve_address.h
grpc_resolved_address
Definition: resolved_address.h:34
grpc_core::URI::Parse
static absl::StatusOr< URI > Parse(absl::string_view uri_text)
Definition: uri_parser.cc:209
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
LLVMFuzzerTestOneInput
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
Definition: sockaddr_utils_fuzzer_test.cc:29
memcpy
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
GRPC_MAX_SOCKADDR_SIZE
#define GRPC_MAX_SOCKADDR_SIZE
Definition: resolve_address.h:35
GPR_ASSERT
#define GPR_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:94
grpc.h
grpc_resolved_address::len
socklen_t len
Definition: resolved_address.h:36
data
char data[kBufferLength]
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
stdint.h
absl::StatusOr::ok
ABSL_MUST_USE_RESULT bool ok() const
Definition: abseil-cpp/absl/status/statusor.h:491
squelch
bool squelch
Definition: sockaddr_utils_fuzzer_test.cc:27
absl::StatusOr::value
const T & value() const &ABSL_ATTRIBUTE_LIFETIME_BOUND
Definition: abseil-cpp/absl/status/statusor.h:687
absl::StatusOr< std::string >
uri_parser.h
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
grpc_sockaddr_to_uri
absl::StatusOr< std::string > grpc_sockaddr_to_uri(const grpc_resolved_address *resolved_addr)
Definition: sockaddr_utils.cc:260
grpc_resolved_address::addr
char addr[GRPC_MAX_SOCKADDR_SIZE]
Definition: resolved_address.h:35


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:13