/src/tinysparql/fuzzing/fuzz_ontology_turtle.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright 2025 Red Hat Inc. |
3 | | * |
4 | | * SPDX-License-Identifier: LGPL-2.1-or-later |
5 | | * |
6 | | * This library is free software; you can redistribute it and/or |
7 | | * modify it under the terms of the GNU Lesser General Public |
8 | | * License as published by the Free Software Foundation; either |
9 | | * version 2.1 of the License, or (at your option) any later version. |
10 | | * |
11 | | * This library 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 GNU |
14 | | * Lesser General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU Lesser General Public |
17 | | * License along with this library; if not, see <http://www.gnu.org/licenses/>. |
18 | | * |
19 | | * Author: Carlos Garnacho <carlosg@gnome.org> |
20 | | */ |
21 | | |
22 | | #include "fuzz.h" |
23 | | |
24 | 9.72k | #define MAX_SIZE 200 * 1024 |
25 | | |
26 | | int |
27 | | LLVMFuzzerTestOneInput (const unsigned char *data, size_t size) |
28 | 9.72k | { |
29 | 9.72k | TrackerSparqlConnection *conn = NULL; |
30 | 9.72k | GInputStream *istream; |
31 | | |
32 | 9.72k | sqlite3_config (SQLITE_CONFIG_LOOKASIDE, 0, 0); |
33 | | |
34 | 9.72k | fuzz_set_logging_func (); |
35 | | |
36 | 9.72k | if (size > MAX_SIZE) |
37 | 1 | return 0; |
38 | | |
39 | 9.72k | istream = g_memory_input_stream_new_from_data (data, size, NULL); |
40 | | |
41 | 9.72k | conn = tracker_sparql_connection_new_from_rdf (TRACKER_SPARQL_CONNECTION_FLAGS_NONE, |
42 | 9.72k | NULL, |
43 | 9.72k | TRACKER_DESERIALIZE_FLAGS_NONE, |
44 | 9.72k | TRACKER_RDF_FORMAT_TURTLE, |
45 | 9.72k | istream, |
46 | 9.72k | NULL, NULL); |
47 | 9.72k | g_clear_object (&conn); |
48 | 9.72k | g_clear_object (&istream); |
49 | | |
50 | 9.72k | return 0; |
51 | 9.72k | } |