diff options
author | van Hauser <vh@thc.org> | 2024-07-14 11:23:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-14 11:23:51 +0200 |
commit | 19ca7b3761f5abff8b72770d6bbfbde80ef5b985 (patch) | |
tree | 62e6316d91ea348228fe3471bfa59ee01e0e393e /frida_mode/test/dynamic/testinstr.c | |
parent | 53409530b369e560c7f6f37ead5a5db9e116efd0 (diff) | |
parent | 55a2362348cd467b65d6aea33e93ec44c6de1a38 (diff) | |
download | afl++-19ca7b3761f5abff8b72770d6bbfbde80ef5b985.tar.gz |
Merge pull request #2158 from AFLplusplus/dev
push to stable
Diffstat (limited to 'frida_mode/test/dynamic/testinstr.c')
-rw-r--r-- | frida_mode/test/dynamic/testinstr.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/frida_mode/test/dynamic/testinstr.c b/frida_mode/test/dynamic/testinstr.c index 0abc61fd..55bf579e 100644 --- a/frida_mode/test/dynamic/testinstr.c +++ b/frida_mode/test/dynamic/testinstr.c @@ -19,32 +19,40 @@ typedef void (*fntestinstrlib)(char *buf, int len); void testinstr(char *buf, int len) { + void *lib = dlopen("testinstrlib.so", RTLD_NOW); if (lib == NULL) { + puts("Library not found"); abort(); + } fntestinstrlib fn = (fntestinstrlib)(dlsym(lib, "testinstrlib")); if (fn == NULL) { + puts("Function not found"); abort(); + } fn(buf, len); + } int main(int argc, char **argv) { - char * file; + + char *file; int fd = -1; off_t len; - char * buf = NULL; + char *buf = NULL; size_t n_read; int result = -1; if (argc != 2) { return 1; } do { + file = argv[1]; printf("file: %s\n", file); @@ -52,33 +60,43 @@ int main(int argc, char **argv) { fd = open(file, O_RDONLY); if (fd < 0) { + perror("open"); break; + } len = lseek(fd, 0, SEEK_END); if (len < 0) { + perror("lseek (SEEK_END)"); break; + } if (lseek(fd, 0, SEEK_SET) != 0) { + perror("lseek (SEEK_SET)"); break; + } printf("len: %ld\n", len); buf = malloc(len); if (buf == NULL) { + perror("malloc"); break; + } n_read = read(fd, buf, len); if (n_read != len) { + perror("read"); break; + } dprintf(STDERR_FILENO, "Running: %s: (%zd bytes)\n", file, n_read); @@ -95,4 +113,6 @@ int main(int argc, char **argv) { if (fd != -1) { close(fd); } return result; + } + |