Coverage Report

Created: 2026-07-16 06:19

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/avahi/fuzz/fuzz-domain.c
Line
Count
Source
1
/***
2
  This file is part of avahi.
3
4
  avahi is free software; you can redistribute it and/or modify it
5
  under the terms of the GNU Lesser General Public License as
6
  published by the Free Software Foundation; either version 2.1 of the
7
  License, or (at your option) any later version.
8
9
  avahi is distributed in the hope that it will be useful, but WITHOUT
10
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11
  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
12
  Public License for more details.
13
14
  You should have received a copy of the GNU Lesser General Public
15
  License along with avahi; if not, write to the Free Software
16
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17
  USA.
18
***/
19
20
#include <assert.h>
21
#include <stdint.h>
22
#include <string.h>
23
24
#include "avahi-common/alternative.h"
25
#include "avahi-common/malloc.h"
26
#include "avahi-common/domain.h"
27
28
#ifdef HAVE_NALLOCFUZZ
29
#include "nallocinc.c"
30
#endif
31
32
965
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
33
965
    char *s = NULL, *t = NULL;
34
965
    int r;
35
36
965
    if(!(s = avahi_malloc(size+1)))
37
0
        return 0;
38
39
965
    memcpy(s, data, size);
40
965
    s[size] = '\0';
41
42
#ifdef HAVE_NALLOCFUZZ
43
    nalloc_start(data, size);
44
#endif
45
46
965
    if (avahi_is_valid_domain_name(s)) {
47
707
        t = avahi_normalize_name_strdup(s);
48
707
#ifndef HAVE_NALLOCFUZZ
49
707
        assert(t);
50
707
        r = avahi_domain_equal(s, t);
51
707
        assert(r);
52
707
#endif
53
707
        avahi_free(t);
54
707
    }
55
56
965
    if ((t = avahi_normalize_name_strdup(s)))
57
965
        assert(avahi_domain_equal(s, t));
58
59
965
    avahi_is_valid_service_type_generic(s);
60
965
    avahi_is_valid_service_type_strict(s);
61
965
    avahi_is_valid_service_subtype(s);
62
965
    avahi_is_valid_service_name(s);
63
965
    avahi_is_valid_host_name(s);
64
965
    avahi_is_valid_fqdn(s);
65
66
965
    avahi_free(avahi_alternative_host_name(s));
67
965
    avahi_free(avahi_alternative_service_name(s));
68
69
965
    avahi_free(t);
70
965
    avahi_free(s);
71
72
#ifdef HAVE_NALLOCFUZZ
73
    nalloc_end();
74
#endif
75
76
965
    return 0;
77
965
}