0
0
mirror of https://github.com/zeux/pugixml.git synced 2024-12-25 20:14:10 +08:00

tests: Add XPath fuzzing

Only fuzz the parser for now.
This commit is contained in:
Arseny Kapoulkine 2017-02-08 08:48:54 -08:00
parent 8b15ae8015
commit 8c62fa9121
6 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1 @@
a/b/c

View File

@ -0,0 +1 @@
sum(nodes) + round(concat(//a[translate(@id, 'abc', '012')]))

View File

@ -0,0 +1 @@
1+2*3 div 4 mod 5-6

View File

@ -0,0 +1 @@
@*/ancestor::*/near-north/*[4]/@*/preceding::text()

View File

@ -0,0 +1 @@
library/nodes[@id=12]/element[@type='translate'][1]

26
tests/fuzz_xpath.cpp Normal file
View File

@ -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;
}