Skip to content

Commit

Permalink
Added fuzzer
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamKorcz committed Apr 21, 2020
1 parent 63c11b0 commit f2df3a5
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/fuzzers/zlog_init_fuzzer.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "zlog.h"

int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
char filename[256];
sprintf(filename, "/tmp/libfuzzer.%d", getpid());

FILE *fp = fopen(filename, "wb");
if (!fp)
return 0;
fwrite(data, size, 1, fp);
fclose(fp);

int rc = zlog_init(filename);
if (rc == 0)
{
zlog_fini();
}
unlink(filename);

return 0;
}

0 comments on commit f2df3a5

Please sign in to comment.