Coverage Report

Created: 2025-11-09 06:45

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/h2o/fuzz/driver_url.cc
Line
Count
Source
1
/*
2
 * Copyright (c) 2016 Fastly, Inc.
3
 *
4
 * Permission is hereby granted, free of charge, to any person obtaining a copy
5
 * of this software and associated documentation files (the "Software"), to
6
 * deal in the Software without restriction, including without limitation the
7
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8
 * sell copies of the Software, and to permit persons to whom the Software is
9
 * furnished to do so, subject to the following conditions:
10
 *
11
 * The above copyright notice and this permission notice shall be included in
12
 * all copies or substantial portions of the Software.
13
 *
14
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20
 * IN THE SOFTWARE.
21
 */
22
23
/*
24
 * This file implements a test harness for using h2o with LibFuzzer.
25
 * See http://llvm.org/docs/LibFuzzer.html for more info.
26
 */
27
#define H2O_USE_EPOLL 1
28
29
#include "h2o.h"
30
#include "h2o/url.h"
31
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
32
554
{
33
554
    h2o_mem_pool_t pool;
34
554
    h2o_url_t url;
35
554
    int ret;
36
37
554
    h2o_mem_init_pool(&pool);
38
39
554
    ret = h2o_url_parse(&pool, (const char *)Data, Size, &url);
40
554
    if (ret != -1) {
41
378
        size_t total = 0, i;
42
378
        assert(url.scheme != NULL);
43
6.03M
        for (i = 0; i < url.authority.len; i++)
44
6.03M
            if (url.authority.base[i])
45
6.03M
                total++;
46
6.03M
        for (i = 0; i < url.host.len; i++)
47
6.03M
            if (url.host.base[i])
48
6.03M
                total++;
49
8.90M
        for (i = 0; i < url.path.len; i++)
50
8.90M
            if (url.path.base[i])
51
7.47M
                total++;
52
378
        assert(total <= Size * 2);
53
378
    }
54
55
554
    h2o_mem_clear_pool(&pool);
56
554
    return 0;
57
554
}