/src/xmlsec/tests/oss-fuzz/xmlsec_target.c
Line | Count | Source |
1 | | #include <stdint.h> |
2 | | #include <xmlsec/buffer.h> |
3 | | #include <xmlsec/parser.h> |
4 | | |
5 | 2.35M | void ignore (void* ctx, const char* msg, ...) { |
6 | | // Error handler to avoid spam of error messages from libxml parser. |
7 | 2.35M | } |
8 | | |
9 | 20.6k | int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
10 | 20.6k | xmlSetGenericErrorFunc(NULL, &ignore); |
11 | 20.6k | xmlSecBufferPtr buf = xmlSecBufferCreate(size); |
12 | 20.6k | xmlSecBufferSetData(buf, data, size); |
13 | 20.6k | xmlDocPtr doc = xmlSecParseMemory(xmlSecBufferGetData(buf), |
14 | 20.6k | xmlSecBufferGetSize(buf), 0); |
15 | | |
16 | 20.6k | if (doc != NULL) xmlFreeDoc(doc); |
17 | 20.6k | xmlSecBufferDestroy(buf); |
18 | 20.6k | return 0; |
19 | 20.6k | } |