Coverage Report

Created: 2025-11-24 06:44

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.11k
{
6
1.11k
        fuzz_set_logging_func ();
7
8
        /* Each content type has a different code path so lets test them all. */
9
1.11k
        static const char* content_types[] = {
10
1.11k
                NULL,
11
1.11k
                "application/unknown",
12
1.11k
                "text/plain",
13
1.11k
                "text/html",
14
1.11k
                "text/xml",
15
1.11k
                "image/something",
16
1.11k
                "video/something",
17
1.11k
        };
18
19
1.11k
        GBytes *bytes = g_bytes_new (data, size);
20
1.11k
        SoupContentSniffer *sniffer = soup_content_sniffer_new ();
21
22
8.95k
        for (unsigned i = 0; i < G_N_ELEMENTS(content_types); i++) {
23
7.83k
                SoupMessage *msg = soup_message_new (SOUP_METHOD_GET, "https://example.org");
24
7.83k
                if (content_types[i])
25
6.71k
                        soup_message_headers_set_content_type (soup_message_get_response_headers(msg), content_types[i], NULL);
26
27
7.83k
                char *content_type = soup_content_sniffer_sniff (sniffer, msg, bytes, NULL);
28
29
7.83k
                g_object_unref (msg);
30
7.83k
                g_free (content_type);
31
7.83k
        }
32
33
1.11k
        g_bytes_unref (bytes);
34
1.11k
        g_object_unref (sniffer);
35
36
1.11k
        return 0;
37
1.11k
}