Coverage Report

Created: 2025-03-18 06:55

/src/wget2/fuzz/libwget_robots_parse_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
/*
21
 * covers code in libwget/robots.c
22
 */
23
24
#include <config.h>
25
26
#include <assert.h> // assert
27
#include <stdint.h> // uint8_t
28
#include <stdlib.h> // malloc, free
29
#include <string.h> // memcpy
30
31
#include "wget.h"
32
#include "fuzzer.h"
33
34
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
35
546
{
36
546
  wget_robots *robots;
37
546
  char *in = (char *) malloc(size + 1);
38
39
546
  assert(in != NULL);
40
41
  // 0 terminate
42
546
  memcpy(in, data, size);
43
546
  in[size] = 0;
44
45
546
  if (wget_robots_parse(&robots, in, "wget2") == WGET_E_SUCCESS)
46
545
    wget_robots_free(&robots);
47
48
546
  free(in);
49
50
546
  return 0;
51
546
}