summaryrefslogtreecommitdiff
path: root/tests/fuzz_xpath.cpp
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2017-02-11 13:51:39 -0800
committerGitHub <noreply@github.com>2017-02-11 13:51:39 -0800
commit03e4b8de929328eb5cbb031ff535c50396d43bb9 (patch)
tree0552947207245d263abffb91e1c6b1d92b86e653 /tests/fuzz_xpath.cpp
parent02c599f52b8817916405b4263da3616a55f77632 (diff)
parentec984370fb525d0cbc20b009f69c9c5eaec022a7 (diff)
Merge pull request #132 from zeux/fuzz
Improve fuzzing support
Diffstat (limited to 'tests/fuzz_xpath.cpp')
-rw-r--r--tests/fuzz_xpath.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/fuzz_xpath.cpp b/tests/fuzz_xpath.cpp
new file mode 100644
index 0000000..c7ff4cd
--- /dev/null
+++ b/tests/fuzz_xpath.cpp
@@ -0,0 +1,26 @@
+#include "../src/pugixml.hpp"
+
+#include <stdint.h>
+#include <string.h>
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
+{
+ char* text = new char[Size + 1];
+ memcpy(text, Data, Size);
+ text[Size] = 0;
+
+#ifdef PUGIXML_NO_EXCEPTIONS
+ pugi::xpath_query q(text);
+#else
+ try
+ {
+ pugi::xpath_query q(text);
+ }
+ catch (pugi::xpath_exception&)
+ {
+ }
+#endif
+
+ delete[] text;
+ return 0;
+}