Coverage Report

Created: 2025-11-24 06:34

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
537
{
33
537
    h2o_mem_pool_t pool;
34
537
    h2o_url_t url;
35
537
    int ret;
36
37
537
    h2o_mem_init_pool(&pool);
38
39
537
    ret = h2o_url_parse(&pool, (const char *)Data, Size, &url);
40
537
    if (ret != -1) {
41
371
        size_t total = 0, i;
42
371
        assert(url.scheme != NULL);
43
4.29M
        for (i = 0; i < url.authority.len; i++)
44
4.29M
            if (url.authority.base[i])
45
4.28M
                total++;
46
4.28M
        for (i = 0; i < url.host.len; i++)
47
4.28M
            if (url.host.base[i])
48
4.27M
                total++;
49
10.6M
        for (i = 0; i < url.path.len; i++)
50
10.6M
            if (url.path.base[i])
51
7.85M
                total++;
52
371
        assert(total <= Size * 2);
53
371
    }
54
55
537
    h2o_mem_clear_pool(&pool);
56
537
    return 0;
57
537
}