summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2017-04-25 14:54:59 +0200
committerGravatar Nikias Bassen2017-04-25 14:54:59 +0200
commit5c6e695ca942f9a417d24e58f14d51f3e8e1885d (patch)
tree7eef70ace704c440baea74fff06cc623f800d303
parent62ec804736435fa34e37e66e228e17e2aacee1d7 (diff)
downloadlibplist-5c6e695ca942f9a417d24e58f14d51f3e8e1885d.tar.gz
libplist-5c6e695ca942f9a417d24e58f14d51f3e8e1885d.tar.bz2
Add fuzzing targets for libFuzzer used by Google's OSS-Fuzz
-rw-r--r--fuzz/bplist.dict1
-rw-r--r--fuzz/bplist_fuzzer.cc32
-rw-r--r--fuzz/bplist_fuzzer.options3
-rw-r--r--fuzz/xplist.dict51
-rw-r--r--fuzz/xplist_fuzzer.cc32
-rw-r--r--fuzz/xplist_fuzzer.options3
6 files changed, 122 insertions, 0 deletions
diff --git a/fuzz/bplist.dict b/fuzz/bplist.dict
new file mode 100644
index 0000000..bb0ea5d
--- /dev/null
+++ b/fuzz/bplist.dict
@@ -0,0 +1 @@
header_bplist = "bplist00"
diff --git a/fuzz/bplist_fuzzer.cc b/fuzz/bplist_fuzzer.cc
new file mode 100644
index 0000000..17d0649
--- /dev/null
+++ b/fuzz/bplist_fuzzer.cc
@@ -0,0 +1,32 @@
1/*
2 * bplist_fuzzer.cc
3 * binary plist fuzz target for libFuzzer
4 *
5 * Copyright (c) 2017 Nikias Bassen All Rights Reserved.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include <plist/plist.h>
23#include <stdio.h>
24
25extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data, size_t size)
26{
27 plist_t root_node = NULL;
28 plist_from_bin(reinterpret_cast<const char*>(data), size, &root_node);
29 plist_free(root_node);
30
31 return 0;
32}
diff --git a/fuzz/bplist_fuzzer.options b/fuzz/bplist_fuzzer.options
new file mode 100644
index 0000000..c0689b2
--- /dev/null
+++ b/fuzz/bplist_fuzzer.options
@@ -0,0 +1,3 @@
1[libfuzzer]
2max_len = 4096
3dict = bplist.dict
diff --git a/fuzz/xplist.dict b/fuzz/xplist.dict
new file mode 100644
index 0000000..48b0367
--- /dev/null
+++ b/fuzz/xplist.dict
@@ -0,0 +1,51 @@
1################################################################################
2#
3# AFL dictionary for XML Property Lists
4# ----------------------
5#
6# Several basic syntax elements and attributes for libplist.
7#
8# Created by Nikias Bassen <nikias@gmx.li>
9# Adapted from libxml2's dict file (created by Michal Zalewski <lcamtuf@google.com>)
10#
11
12attr_encoding=" encoding=\"1\""
13attr_generic=" a=\"1\""
14attr_version=" version=\"1\""
15
16entity_builtin="&lt;"
17entity_decimal="&#1;"
18entity_external="&a;"
19entity_hex="&#x1;"
20
21string_cdata="CDATA"
22string_dashes="--"
23string_empty="EMPTY"
24string_empty_dblquotes="\"\""
25string_empty_quotes="''"
26string_parentheses="()"
27string_pcdata="#PCDATA"
28string_percent="%a"
29string_public="PUBLIC"
30string_utf8="UTF-8"
31
32tag_cdata="<![CDATA["
33tag_close="</plist>"
34tag_doctype="<!DOCTYPE"
35tag_open="<plist>"
36tag_open_close="<plist />"
37tag_open_exclamation="<!"
38tag_open_q="<?"
39tag_sq2_close="]]>"
40tag_xml_q="<?xml?>"
41tag_array="<array>"
42tag_data="<data>"
43tag_date="<date>"
44tag_dict="<dict>"
45tag_false="<false/>"
46tag_integer="<integer>"
47tag_key="<key>"
48tag_plist="<plist>"
49tag_real="<real>"
50tag_string="<string>"
51tag_true="<true/>"
diff --git a/fuzz/xplist_fuzzer.cc b/fuzz/xplist_fuzzer.cc
new file mode 100644
index 0000000..c477c4d
--- /dev/null
+++ b/fuzz/xplist_fuzzer.cc
@@ -0,0 +1,32 @@
1/*
2 * xplist_fuzzer.cc
3 * XML plist fuzz target for libFuzzer
4 *
5 * Copyright (c) 2017 Nikias Bassen All Rights Reserved.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include <plist/plist.h>
23#include <stdio.h>
24
25extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data, size_t size)
26{
27 plist_t root_node = NULL;
28 plist_from_xml(reinterpret_cast<const char*>(data), size, &root_node);
29 plist_free(root_node);
30
31 return 0;
32}
diff --git a/fuzz/xplist_fuzzer.options b/fuzz/xplist_fuzzer.options
new file mode 100644
index 0000000..bad5dac
--- /dev/null
+++ b/fuzz/xplist_fuzzer.options
@@ -0,0 +1,3 @@
1[libfuzzer]
2max_len = 4096
3dict = xplist.dict