2 * Copyright (C) 2017 Edward Hervey <bilboed@bilboed.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 /* Local fuzzer runner */
23 extern int LLVMFuzzerTestOneInput (const guint8 * data, size_t size);
26 test_file (gchar * filename)
33 /* if filename is a directory, process the contents */
34 if ((dir = g_dir_open (filename, 0, NULL))) {
37 while ((entry = g_dir_read_name (dir))) {
40 spath = g_strconcat (filename, G_DIR_SEPARATOR_S, entry, NULL);
49 /* Make sure path is absolute */
50 if (!g_path_is_absolute (filename)) {
53 curdir = g_get_current_dir ();
54 path = g_build_filename (curdir, filename, NULL);
57 path = g_strdup (filename);
59 /* Check if path exists */
60 if (g_file_get_contents (path, &contents, &length, NULL)) {
61 g_print (">>> %s (%" G_GSIZE_FORMAT " bytes)\n", path, length);
62 LLVMFuzzerTestOneInput ((const guint8 *) contents, length);
70 main (int argc, gchar ** argv)
74 for (i = 1; i < argc; i++)