Coverage Report

Created: 2025-12-31 07:08

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wget2/fuzz/libwget_html_url_fuzzer.c
Line
Count
Source
1
/*
2
 * Copyright (c) 2017-2024 Free Software Foundation, Inc.
3
 *
4
 * This file is part of libwget.
5
 *
6
 * Libwget is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU Lesser General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * Libwget is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public License
17
 * along with libwget.  If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
#include <config.h>
21
22
#include <assert.h>
23
#include <stdio.h>
24
#include <stdint.h>
25
#include <stdlib.h>
26
#include <string.h>
27
28
#include "wget.h"
29
#include "fuzzer.h"
30
31
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
32
19.7k
{
33
19.7k
  if (size > 10000) // same as max_len = 10000 in .options file
34
43
    return 0;
35
36
19.6k
  char *in = (char *) malloc(size + 2);
37
19.6k
  assert(in != NULL);
38
39
  // 0 terminate
40
19.6k
  memcpy(in, data, size);
41
19.6k
  in[size] = in[size + 1] = 0;
42
43
19.6k
  wget_html_parsed_result *res = wget_html_get_urls_inline(in, NULL, NULL);
44
19.6k
  wget_html_free_urls_inline(&res);
45
46
19.6k
  free(in);
47
48
19.6k
  return 0;
49
19.6k
}