File: fuzz.c

package info (click to toggle)
haskell-hexml 0.3.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 116 kB
  • sloc: ansic: 557; haskell: 209; makefile: 6
file content (26 lines) | stat: -rw-r--r-- 518 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "hexml.c"

int main(int ac, char** av)
{
#ifdef __AFL_HAVE_MANUAL_CONTROL
    __AFL_INIT();
#endif

    FILE *f = fopen(av[1], "rb");
    fseek(f, 0, SEEK_END);
    size_t fsize = ftell(f);
    rewind(f);

    char* string = malloc(fsize+1);
    memset(string, 0, fsize+1);
    (void) fread(string, fsize, 1, f);
    fclose(f);

    document *doc = hexml_document_parse(string, fsize);
    hexml_document_free(doc);
    free(string);
    return 0;
}