]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - libblkid/src/fuzz.c
7 static int process_file(const char *name
)
10 blkid_probe pr
= blkid_new_probe_from_filename(name
);
12 blkid_probe_enable_partitions(pr
, TRUE
);
13 blkid_probe_set_partitions_flags(pr
, FALSE
);
14 blkid_probe_enable_superblocks(pr
, TRUE
);
15 blkid_probe_set_superblocks_flags(pr
, BLKID_SUBLKS_DEFAULT
| BLKID_SUBLKS_FSINFO
| BLKID_SUBLKS_MAGIC
| BLKID_SUBLKS_VERSION
| BLKID_SUBLKS_BADCSUM
);
16 rc
= blkid_do_safeprobe(pr
) == -1 ? -1 : 0;
22 int LLVMFuzzerTestOneInput(const uint8_t *data
, size_t size
) {
24 char name
[] = "/tmp/test-script-fuzz.XXXXXX";
26 fd
= mkostemp(name
, O_RDWR
|O_CREAT
|O_EXCL
|O_CLOEXEC
);
28 err(EXIT_FAILURE
, "mkostemp() failed");
30 if (write(fd
, data
, size
) != (ssize_t
)size
)
41 int main(int argc
, char **argv
)
43 for (int i
= 1; i
< argc
; i
++) {
44 printf("%s ", argv
[i
]);
45 if (process_file(argv
[i
]) == 0)