Coverage Report

Created: 2026-09-04 06:21

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libsoup/fuzzing/fuzz_content_sniffer.c
Line
Count
Source
1
#include "fuzz.h"
2
3
int
4
LLVMFuzzerTestOneInput (const unsigned char *data, size_t size)
5
1.21k
{
6
1.21k
        fuzz_set_logging_func ();
7
8
        /* Each content type has a different code path so lets test them all. */
9
1.21k
        static const char* content_types[] = {
10
1.21k
                NULL,
11
1.21k
                "application/unknown",
12
1.21k
                "text/plain",
13
1.21k
                "text/html",
14
1.21k
                "text/xml",
15
1.21k
                "image/something",
16
1.21k
                "video/something",
17
1.21k
        };
18
19
1.21k
        GBytes *bytes = g_bytes_new (data, size);
20
1.21k
        SoupContentSniffer *sniffer = soup_content_sniffer_new ();
21
22
9.72k
        for (unsigned i = 0; i < G_N_ELEMENTS(content_types); i++) {
23
8.51k
                SoupMessage *msg = soup_message_new (SOUP_METHOD_GET, "https://example.org");
24
8.51k
                if (content_types[i])
25
7.29k
                        soup_message_headers_set_content_type (soup_message_get_response_headers(msg), content_types[i], NULL);
26
27
8.51k
                char *content_type = soup_content_sniffer_sniff (sniffer, msg, bytes, NULL);
28
29
8.51k
                g_object_unref (msg);
30
8.51k
                g_free (content_type);
31
8.51k
        }
32
33
1.21k
        g_bytes_unref (bytes);
34
1.21k
        g_object_unref (sniffer);
35
36
1.21k
        return 0;
37
1.21k
}