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