Coverage Report

Created: 2025-01-26 06:54

/src/boost_filesystem_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/filesystem.hpp>
14
#include <boost/filesystem/fstream.hpp>
15
#include <string>
16
#include <fuzzer/FuzzedDataProvider.h>
17
18
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
19
16.0k
{
20
16.0k
    FuzzedDataProvider fdp(data, size);
21
16.0k
    try {
22
16.0k
        boost::filesystem::path p(fdp.ConsumeRandomLengthString(5));
23
24
16.0k
        p.replace_filename(fdp.ConsumeRandomLengthString(5));
25
        
26
16.0k
        p.has_extension();
27
16.0k
        p.extension();
28
16.0k
        p.replace_extension(fdp.ConsumeRandomLengthString(3));
29
        
30
16.0k
        boost::filesystem::path p1(fdp.ConsumeRandomLengthString(5));
31
16.0k
        p.concat(p1);
32
16.0k
        p.append(p1);
33
16.0k
        p.remove_filename_and_trailing_separators();
34
16.0k
        p /= (p1);
35
16.0k
        p += (p1);
36
        
37
16.0k
        p.lexically_relative(p1);
38
16.0k
        p.filename_is_dot();
39
16.0k
        p.remove_filename();
40
        
41
16.0k
        p.swap(p1);
42
16.0k
        p.root_directory();
43
16.0k
        p.relative_path();
44
16.0k
        p.parent_path();
45
16.0k
        p.has_stem();
46
16.0k
    } catch(...) {
47
10.6k
    }
48
16.0k
    return 0;
49
16.0k
}