about summary refs log tree commit diff
path: root/libAflDyninst.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libAflDyninst.cpp')
-rw-r--r--libAflDyninst.cpp23
1 files changed, 8 insertions, 15 deletions
diff --git a/libAflDyninst.cpp b/libAflDyninst.cpp
index ef9d046..3374010 100644
--- a/libAflDyninst.cpp
+++ b/libAflDyninst.cpp
@@ -22,36 +22,39 @@ static unsigned short prev_id;
 static long saved_di;
 register long rdi asm("di");    // the warning is fine - we need the warning because of a bug in dyninst
 
+#define PRINT_ERROR(string) write(2, string, strlen(string))
+
 void initAflForkServer() {
+  // we can not use fprint* stdout/stderr functions here, it fucks up some programs
   char *shm_env_var = getenv(SHM_ENV_VAR);
 
   if (!shm_env_var) {
-    printf("Error getting shm\n");
+    PRINT_ERROR("Error getting shm\n");
     return;
   }
   shm_id = atoi(shm_env_var);
   trace_bits = (u8 *) shmat(shm_id, NULL, 0);
   if (trace_bits == (u8 *) - 1) {
-    perror("shmat");
+    PRINT_ERROR("Error: shmat\n");
     return;
   }
   // enter fork() server thyme!
   int n = write(FORKSRV_FD + 1, &__afl_temp_data, 4);
 
   if (n != 4) {
-    printf("Error writting fork server\n");
+    PRINT_ERROR("Error writting fork server\n");
     return;
   }
   while (1) {
     n = read(FORKSRV_FD, &__afl_temp_data, 4);
     if (n != 4) {
-      printf("Error reading fork server %x\n", __afl_temp_data);
+      PRINT_ERROR("Error reading fork server\n");
       return;
     }
 
     __afl_fork_pid = fork();
     if (__afl_fork_pid < 0) {
-      printf("Error on fork()\n");
+      PRINT_ERROR("Error on fork()\n");
       return;
     }
     if (__afl_fork_pid == 0) {
@@ -81,18 +84,8 @@ void bbCallback(unsigned short id) {
 
 void save_rdi() {
   saved_di = rdi;
-/*
-  asm("pop %rax"); // take care of rip
-  asm("push %rdi");
-  asm("push %rax");
-*/
 }
 
 void restore_rdi() {
   rdi = saved_di;
-/*
-  asm("pop %rax"); // take care of rip
-  asm("pop %rdi");
-  asm("push %rax");
-*/
 }