Coverage Report

Created: 2025-09-27 06:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/boost_stralg_fuzzer.cc
Line
Count
Source
1
/* Copyright 2024 Google LLC
2
Licensed under the Apache License, Version 2.0 (the "License");
3
you may not use this file except in compliance with the License.
4
You may obtain a copy of the License at
5
      http://www.apache.org/licenses/LICENSE-2.0
6
Unless required by applicable law or agreed to in writing, software
7
distributed under the License is distributed on an "AS IS" BASIS,
8
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9
See the License for the specific language governing permissions and
10
limitations under the License.
11
*/
12
// The ideal place for this fuzz target is the boost repository.
13
#include <boost/algorithm/string.hpp>
14
#include <boost/algorithm/string/find_iterator.hpp>
15
#include <boost/throw_exception.hpp>
16
#include <string>
17
#include <iterator>
18
#include <fuzzer/FuzzedDataProvider.h>
19
20
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
21
330
{
22
330
    try{
23
330
        FuzzedDataProvider fdp(Data, Size);
24
330
        std::string x = fdp.ConsumeRemainingBytesAsString();
25
26
330
        boost::algorithm::to_upper_copy(x);
27
330
        boost::algorithm::trim_copy(x);
28
330
        boost::algorithm::replace_all_copy(x, "A", "LHVBSLDFVSDJHKG");
29
30
330
        typedef boost::algorithm::find_iterator<std::string::iterator> string_find_iterator;
31
330
        for(string_find_iterator It=boost::algorithm::make_find_iterator(x, boost::algorithm::first_finder("A", boost::algorithm::is_iequal()));
32
4.62M
            It!=string_find_iterator();
33
4.62M
            ++It
34
4.62M
            ){
35
4.62M
                boost::copy_range<std::string>(*It);
36
4.62M
        }
37
38
330
        typedef boost::algorithm::split_iterator<std::string::iterator> string_split_iterator;
39
330
        for(string_split_iterator It=boost::algorithm::make_split_iterator(x, boost::algorithm::first_finder(" ", boost::algorithm::is_iequal()));
40
78.9k
            It!=string_split_iterator();
41
78.6k
            ++It
42
78.6k
            ){
43
78.6k
                boost::copy_range<std::string>(*It);
44
78.6k
        }
45
46
330
        boost::algorithm::erase_all_copy(x, "A");
47
330
        boost::algorithm::erase_head_copy(x, 2147483647);
48
330
        boost::algorithm::erase_head_copy(x, -2147483648);
49
330
        boost::algorithm::erase_tail_copy(x, 2147483647);
50
330
        boost::algorithm::erase_tail_copy(x, -2147483648);
51
52
330
    } catch(...) {
53
0
    }
54
330
    return 0;
55
330
}