fuzz: Improve debug output of reader fuzzer

This commit is contained in:
Nick Wellnhofer 2024-07-09 13:56:49 +02:00
parent 5935471732
commit 8c4cc0be35

View File

@ -15,9 +15,7 @@
#include <string.h>
#if 0
#define DEBUG printf
#else
#define DEBUG noop
#define DEBUG
#endif
typedef enum {
@ -81,15 +79,12 @@ typedef enum {
OP_MAX
} opType;
static void
noop(const char *fmt, ...) {
(void) fmt;
}
static void
startOp(const char *name) {
(void) name;
DEBUG("%s\n", name);
#ifdef DEBUG
fprintf(stderr, "%s\n", name);
#endif
}
int
@ -130,6 +125,19 @@ LLVMFuzzerTestOneInput(const char *data, size_t size) {
if (docBuffer == NULL)
goto exit;
#ifdef DEBUG
fprintf(stderr, "Input document (%d bytes):\n", (int) docSize);
for (i = 0; (size_t) i < docSize; i++) {
int c = (unsigned char) docBuffer[i];
if ((c == '\n' || (c >= 0x20 && c <= 0x7E)))
putc(c, stderr);
else
fprintf(stderr, "\\x%02X", c);
}
fprintf(stderr, "\nEOF\n");
#endif
xmlFuzzMemSetLimit(maxAlloc);
reader = xmlReaderForMemory(docBuffer, docSize, NULL, NULL, opts);
if (reader == NULL)