Coverage Report

Created: 2023-05-25 06:18

/proc/self/cwd/fuzz/fuzz_parse.cc
Line
Count
Source (jump to first uncovered line)
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
9.61k
#define MAX_RECURSION 0x100
23
24
9.61k
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
25
9.61k
    std::string str (reinterpret_cast<const char*>(data), size);
26
9.61k
    google::api::expr::parser::ParserOptions options;
27
9.61k
    options.max_recursion_depth = MAX_RECURSION;
28
9.61k
    try {
29
9.61k
        auto parse_status = google::api::expr::parser::Parse(str, "fuzzinput", options);
30
9.61k
        if (!parse_status.ok()) {
31
7.11k
            parse_status.status().message();
32
7.11k
        }
33
9.61k
    } catch (const std::exception& e) {
34
0
        return 0;
35
0
    }
36
9.61k
    return 0;
37
9.61k
}