ref: 2dcaa4af26a51d0d022f9ec6d2a7ad490d0e87d7
parent: dd4e50bef04f9c87866112e14151a24ead53699d
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Mon Mar 4 20:11:02 EST 2024
readtags: add a block used for fuzzing
--- a/examples/readtags.c
+++ b/examples/readtags.c
@@ -62,7 +62,6 @@
int
main(int argc, char **argv)
{
- int i;
char buf[256];
Aux aux;
Tagctx ctx = {
@@ -77,9 +76,19 @@
if(argc < 2){
printf("usage: readtags FILE...\n");
- return -1;
+ return 1;
}
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
+ // this block is for fuzzing only, ignore
+ while(__AFL_LOOP(10000)){
+ if((aux.fd = open(argv[1], O_RDONLY)) >= 0){
+ tagsget(&ctx);
+ close(aux.fd);
+ }
+ }
+#else
+ int i;
for(i = 1; i < argc; i++){
printf("*** %s\n", argv[i]);
if((aux.fd = open(argv[i], O_RDONLY)) < 0)
@@ -101,5 +110,6 @@
}
printf("\n");
}
+#endif
return 0;
}