afl-fuzz.c
static void readjust_case_order(void){
  u32 case_hash_location = 1;
  u32 tmp_hash_total = hash_total;
  while(case_hash_location < tmp_hash_total){
  //while(case_hash_location < hash_total){
    struct hash_map * hash_index = cksum_hash_map[hash_cksum_now[case_hash_location]];
    while(hash_index){
      /*
      if(hash_index->testcase_num <= 1){
        hash_index = hash_index->next;
        continue;
      }else{
      */
      if(hash_index->testcase_num > 1){
        struct top_mem* fix_cur_case = hash_index->score_queue;        
        struct top_mem* fix_cur_case_before = hash_index->score_queue;
        while(fix_cur_case->next != NULL){
          struct top_mem* cur_case = fix_cur_case;
          struct top_mem* cur_case_before = fix_cur_case;
          struct top_mem* now_max_case = fix_cur_case;
          struct top_mem* now_max_case_before = fix_cur_case;
          double now_max_score = cur_case->testcase->score;
          while(cur_case){
            if(cur_case->testcase->score > now_max_score){
              now_max_case_before = cur_case_before;
              now_max_case = cur_case;
              now_max_score = cur_case->testcase->score;
            }
            cur_case_before = cur_case;
            cur_case = cur_case->next;
          }
          if(likely(fix_cur_case != hash_index->score_queue)){
            if(now_max_case_before == now_max_case){
              fix_cur_case_before = fix_cur_case_before->next; 
            }else{
              now_max_case_before->next = now_max_case->next; 
              now_max_case->next = fix_cur_case_before->next;
              fix_cur_case_before->next = now_max_case;
              fix_cur_case_before = fix_cur_case_before->next;  
            }
          }else{  
            if(now_max_case_before == now_max_case){
              fix_cur_case_before = hash_index->score_queue; 
            }else{
              now_max_case_before->next = now_max_case->next; 
              now_max_case->next = hash_index->score_queue; 
              hash_index->score_queue = now_max_case;
              fix_cur_case_before = hash_index->score_queue;  
            }
          }
          fix_cur_case = fix_cur_case_before->next; 
        }
      }
      hash_index = hash_index->next;
    }
    case_hash_location++;
  }
}
/* Re-adjust the case order in score_queue according to the modified score. Created by LH. */
Re-adjust the case order in score_queue according to the modified score. Created by LH.
Re - adjust the case order in score_queue according to the modified score . Created by LH .
static void readjust_case_order(void){
  u32 case_hash_location = 1;
  u32 tmp_hash_total = hash_total;
  while(case_hash_location < tmp_hash_total){
    struct hash_map * hash_index = cksum_hash_map[hash_cksum_now[case_hash_location]];
    while(hash_index){
      if(hash_index->testcase_num > 1){
        struct top_mem* fix_cur_case = hash_index->score_queue;        
        struct top_mem* fix_cur_case_before = hash_index->score_queue;
        while(fix_cur_case->next != NULL){
          struct top_mem* cur_case = fix_cur_case;
          struct top_mem* cur_case_before = fix_cur_case;
          struct top_mem* now_max_case = fix_cur_case;
          struct top_mem* now_max_case_before = fix_cur_case;
          double now_max_score = cur_case->testcase->score;
          while(cur_case){
            if(cur_case->testcase->score > now_max_score){
              now_max_case_before = cur_case_before;
              now_max_case = cur_case;
              now_max_score = cur_case->testcase->score;
            }
            cur_case_before = cur_case;
            cur_case = cur_case->next;
          }
          if(likely(fix_cur_case != hash_index->score_queue)){
            if(now_max_case_before == now_max_case){
              fix_cur_case_before = fix_cur_case_before->next; 
            }else{
              now_max_case_before->next = now_max_case->next; 
              now_max_case->next = fix_cur_case_before->next;
              fix_cur_case_before->next = now_max_case;
              fix_cur_case_before = fix_cur_case_before->next;  
            }
          }else{  
            if(now_max_case_before == now_max_case){
              fix_cur_case_before = hash_index->score_queue; 
            }else{
              now_max_case_before->next = now_max_case->next; 
              now_max_case->next = hash_index->score_queue; 
              hash_index->score_queue = now_max_case;
              fix_cur_case_before = hash_index->score_queue;  
            }
          }
          fix_cur_case = fix_cur_case_before->next; 
        }
      }
      hash_index = hash_index->next;
    }
    case_hash_location++;
  }
}
static void readjust_case_order ( void ) { u32 case_hash_location = 1 ; u32 tmp_hash_total = hash_total ; while ( case_hash_location < tmp_hash_total ) { struct hash_map * hash_index = cksum_hash_map [ hash_cksum_now [ case_hash_location ] ] ; while ( hash_index ) { if ( hash_index -> testcase_num > 1 ) { struct top_mem * fix_cur_case = hash_index -> score_queue ; struct top_mem * fix_cur_case_before = hash_index -> score_queue ; while ( fix_cur_case -> next != NULL ) { struct top_mem * cur_case = fix_cur_case ; struct top_mem * cur_case_before = fix_cur_case ; struct top_mem * now_max_case = fix_cur_case ; struct top_mem * now_max_case_before = fix_cur_case ; double now_max_score = cur_case -> testcase -> score ; while ( cur_case ) { if ( cur_case -> testcase -> score > now_max_score ) { now_max_case_before = cur_case_before ; now_max_case = cur_case ; now_max_score = cur_case -> testcase -> score ; } cur_case_before = cur_case ; cur_case = cur_case -> next ; } if ( likely ( fix_cur_case != hash_index -> score_queue ) ) { if ( now_max_case_before == now_max_case ) { fix_cur_case_before = fix_cur_case_before -> next ; } else { now_max_case_before -> next = now_max_case -> next ; now_max_case -> next = fix_cur_case_before -> next ; fix_cur_case_before -> next = now_max_case ; fix_cur_case_before = fix_cur_case_before -> next ; } } else { if ( now_max_case_before == now_max_case ) { fix_cur_case_before = hash_index -> score_queue ; } else { now_max_case_before -> next = now_max_case -> next ; now_max_case -> next = hash_index -> score_queue ; hash_index -> score_queue = now_max_case ; fix_cur_case_before = hash_index -> score_queue ; } } fix_cur_case = fix_cur_case_before -> next ; } } hash_index = hash_index -> next ; } case_hash_location ++ ; } }
Re-adjust the case order in score_queue according to the modified score.
Re - adjust the case order in score_queue according to the modified score .
//while(case_hash_location < hash_total){ /*
      if(hash_index->testcase_num <= 1){
        hash_index = hash_index->next;
        continue;
      }else{
      */