mirror of
https://github.com/zeux/pugixml.git
synced 2024-12-26 12:41:06 +08:00
tests: Add XPath fuzzing
Only fuzz the parser for now.
This commit is contained in:
parent
8b15ae8015
commit
8c62fa9121
1
tests/data_fuzz_xpath/basic.xpath
Normal file
1
tests/data_fuzz_xpath/basic.xpath
Normal file
@ -0,0 +1 @@
|
||||
a/b/c
|
1
tests/data_fuzz_xpath/functions.xpath
Normal file
1
tests/data_fuzz_xpath/functions.xpath
Normal file
@ -0,0 +1 @@
|
||||
sum(nodes) + round(concat(//a[translate(@id, 'abc', '012')]))
|
1
tests/data_fuzz_xpath/math.xpath
Normal file
1
tests/data_fuzz_xpath/math.xpath
Normal file
@ -0,0 +1 @@
|
||||
1+2*3 div 4 mod 5-6
|
1
tests/data_fuzz_xpath/path.xpath
Normal file
1
tests/data_fuzz_xpath/path.xpath
Normal file
@ -0,0 +1 @@
|
||||
@*/ancestor::*/near-north/*[4]/@*/preceding::text()
|
1
tests/data_fuzz_xpath/predicate.xpath
Normal file
1
tests/data_fuzz_xpath/predicate.xpath
Normal file
@ -0,0 +1 @@
|
||||
library/nodes[@id=12]/element[@type='translate'][1]
|
26
tests/fuzz_xpath.cpp
Normal file
26
tests/fuzz_xpath.cpp
Normal 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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user