isa-l/tests/fuzz/igzip_dump_inflate_corpus.c
Greg Tucker e1470f70f6 igzip: Fixup a few labels and return warnings
Change-Id: Iaf2634a939fc741006895407b4b219a2f2cae98e
Signed-off-by: Greg Tucker <greg.b.tucker@intel.com>
2018-11-29 16:37:56 -07:00

41 lines
897 B
C

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "inflate_std_vects.h"
#define DNAME_MAX 256
#define FNAME_MAX (DNAME_MAX + 81)
int main(int argc, char *argv[])
{
uint8_t *buf;
int i, len, err;
FILE *fout = NULL;
char fname[FNAME_MAX];
char dname[DNAME_MAX];
if (argc != 2) {
fprintf(stderr, "Usage: %s <outdir>\n", argv[0]);
exit(1);
}
strncpy(dname, argv[1], DNAME_MAX - 1);
for (i = 0; i < sizeof(std_vect_array) / sizeof(struct vect_result); i++) {
buf = std_vect_array[i].vector;
len = std_vect_array[i].vector_length;
err = std_vect_array[i].expected_error;
snprintf(fname, FNAME_MAX, "%s/inflate_corp_n%04d_e%04d", dname, i, err);
printf(" writing %s\n", fname);
fout = fopen(fname, "w+");
if (!fout) {
fprintf(stderr, "Can't open %s for writing\n", fname);
exit(1);
}
fwrite(buf, len, 1, fout);
fclose(fout);
}
return 0;
}