Coverage Report

Created: 2025-11-29 07:01

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/proc/self/cwd/fuzz/fuzz_parse.cc
Line
Count
Source
1
// Copyright 2021 Google LLC
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
//
15
////////////////////////////////////////////////////////////////////////////////
16
17
#include <string>
18
19
#include "parser/options.h"
20
#include "parser/parser.h"
21
22
4.23k
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
23
4.23k
    std::string str (reinterpret_cast<const char*>(data), size);
24
4.23k
    google::api::expr::parser::ParserOptions options;
25
4.23k
    options.max_recursion_depth = 128;
26
4.23k
    options.expression_size_codepoint_limit = 1 << 20;
27
4.23k
    try {
28
4.23k
        auto parse_status = google::api::expr::parser::Parse(str, "fuzzinput", options);
29
4.23k
        if (!parse_status.ok()) {
30
2.90k
            static_cast<void>(parse_status.status().message());
31
2.90k
        }
32
4.23k
    } catch (const std::exception& e) {
33
0
        return 0;
34
0
    }
35
4.23k
    return 0;
36
4.23k
}