Coverage Report

Created: 2025-01-26 06:51

/src/boost_uuid_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/uuid/string_generator.hpp>
14
#include <boost/uuid/name_generator.hpp>
15
#include <boost/uuid/uuid_hash.hpp>
16
#include <boost/uuid/uuid.hpp>
17
#include <boost/uuid/uuid_io.hpp>
18
#include <boost/uuid/nil_generator.hpp>
19
#include <fuzzer/FuzzedDataProvider.h>
20
21
using namespace std;
22
using namespace boost::uuids;
23
24
139
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size){
25
    
26
139
    try{
27
139
        FuzzedDataProvider fdp(Data, Size);
28
139
        std::string s = fdp.ConsumeRemainingBytesAsString();
29
30
139
        string_generator gen_string;
31
139
        name_generator_sha1 gen_name(ns::url());
32
139
        hash<uuid> hasher;
33
34
139
        uuid u_string, u_name;
35
36
139
        u_string = gen_string(s);
37
139
        u_name = gen_name(s);
38
        
39
139
        size_t string_hash = hasher(u_string);
40
139
        size_t name_hash = hash_value(u_name);
41
139
        size_t uuid_hash_value = hasher(boost::uuids::uuid());
42
43
139
        string out_string = to_string(u_string);
44
139
        wstring out_wstring = to_wstring(u_string);
45
46
139
        swap(u_string, u_name);
47
139
    } catch(...) {
48
135
    }
49
50
139
    return 0;
51
139
}