jfs.c (877B)
1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <time.h> 4 #include <err.h> 5 6 #include "fsfuzz.h" 7 8 int 9 jfs_init(struct fsfuzz_info *fs_info 10 __attribute__ ((unused))) 11 { 12 srand((unsigned int)time(NULL)); 13 return 0; 14 } 15 16 int 17 jfs_fuzz(struct fsfuzz_info *fs_info) 18 { 19 char *p; 20 size_t offset; 21 size_t i; 22 23 p = fs_info->img; 24 for (i = 0; i < 128; i++) { 25 do { 26 offset = 4096 + rand(); 27 offset %= 65536; 28 if (offset + 3 < fs_info->size) 29 break; 30 } while (1); 31 if (fs_info->verbosity) 32 printf("[+] Patching offset %#lx with 0xffffffff\n", 33 (long)offset); 34 p[offset + 0] = 0xff; 35 p[offset + 1] = 0xff; 36 p[offset + 2] = 0xff; 37 p[offset + 3] = 0xff; 38 } 39 return 0; 40 } 41 42 static struct fsfuzz_ops jfs_fuzz_ops = { 43 .name = "jfs", 44 .init = jfs_init, 45 .fuzz = jfs_fuzz 46 }; 47 48 __attribute__ ((constructor)) 49 static void 50 jfs_register(void) 51 { 52 fsfuzz_register(&jfs_fuzz_ops); 53 }