diff options
author | Omar Polo <op@omarpolo.com> | 2024-07-02 17:47:49 +0000 |
---|---|---|
committer | Omar Polo <op@omarpolo.com> | 2024-07-02 17:47:49 +0000 |
commit | d0fed6eb088ab7f0eec876aea0bb98327c77c2bb (patch) | |
tree | 713c7372ed8f253920410f4f417cb42d44e6140e /regress/fuzz/iri.c | |
parent | bdfea70f305cae0cee71d79f097aff93a69bccf7 (diff) |
initial support for fuzzying
Diffstat (limited to 'regress/fuzz/iri.c')
-rw-r--r-- | regress/fuzz/iri.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/regress/fuzz/iri.c b/regress/fuzz/iri.c new file mode 100644 index 0000000..c9672f4 --- /dev/null +++ b/regress/fuzz/iri.c @@ -0,0 +1,35 @@ +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include "iri.h" + +int +main(void) +{ + struct iri iri; + const char *errstr = NULL; + char buf[64]; + char *line = NULL; + size_t linesize = 0; + ssize_t linelen; + + if ((linelen = getline(&line, &linesize, stdin)) == -1) + return (1); + + if (line[linelen-1] == '\n') + line[--linelen] = '\0'; + + if (parse_iri(line, &iri, &errstr)) { + if (serialize_iri(&iri, buf, sizeof(buf))) + puts(buf); + } + + free(line); + if (ferror(stdin)) { + perror("getline"); + return (1); + } + + return (0); +} |