@@ -68,7 +68,7 @@ static void hook_code(uc_engine *uc, uint64_t address, uint32_t size, void *user
68
68
69
69
/*
70
70
The sample uses strlen, since we don't have a loader or libc, we'll fake it.
71
- We know the strlen will return the lenght of argv[1] that we just planted.
71
+ We know the strlen will return the length of argv[1] that we just planted.
72
72
It will be a lot faster than an actual strlen for this specific purpose.
73
73
*/
74
74
static void hook_strlen (uc_engine * uc , uint64_t address , uint32_t size , void * user_data ) {
@@ -86,7 +86,7 @@ static void hook_strlen(uc_engine *uc, uint64_t address, uint32_t size, void *us
86
86
static uint64_t pad (uint64_t size ) {
87
87
if (size % ALIGNMENT == 0 ) return size ;
88
88
return ((size / ALIGNMENT ) + 1 ) * ALIGNMENT ;
89
- }
89
+ }
90
90
91
91
/* returns the filesize in bytes, -1 or error. */
92
92
static off_t afl_mmap_file (char * filename , char * * buf_ptr ) {
@@ -100,9 +100,9 @@ static off_t afl_mmap_file(char *filename, char **buf_ptr) {
100
100
101
101
off_t in_len = st .st_size ;
102
102
if (in_len == -1 ) {
103
- /* This can only ever happen on 32 bit if the file is exactly 4gb. */
104
- fprintf (stderr , "Filesize of %s too large\n" , filename );
105
- goto exit ;
103
+ /* This can only ever happen on 32 bit if the file is exactly 4gb. */
104
+ fprintf (stderr , "Filesize of %s too large\n" , filename );
105
+ goto exit ;
106
106
}
107
107
108
108
* buf_ptr = mmap (0 , in_len , PROT_READ | PROT_WRITE , MAP_PRIVATE , fd , 0 );
@@ -117,10 +117,10 @@ static off_t afl_mmap_file(char *filename, char **buf_ptr) {
117
117
118
118
/* Place the input at the right spot inside unicorn */
119
119
static bool place_input_callback (
120
- uc_engine * uc ,
121
- char * input ,
122
- size_t input_len ,
123
- uint32_t persistent_round ,
120
+ uc_engine * uc ,
121
+ char * input ,
122
+ size_t input_len ,
123
+ uint32_t persistent_round ,
124
124
void * data
125
125
){
126
126
// printf("Placing input with len %ld to %x\n", input_len, DATA_ADDRESS);
@@ -134,7 +134,7 @@ static bool place_input_callback(
134
134
// Set up the function parameters accordingly RSI, RDI (see calling convention/disassembly)
135
135
uc_reg_write (uc , UC_X86_REG_RSI , & INPUT_LOCATION ); // argv
136
136
uc_reg_write (uc , UC_X86_REG_RDI , & EMULATED_ARGC ); // argc == 2
137
-
137
+
138
138
// We need a valid c string, make sure it never goes out of bounds.
139
139
input [input_len - 1 ] = '\0' ;
140
140
// Write the testcase to unicorn.
@@ -188,13 +188,13 @@ int main(int argc, char **argv, char **envp) {
188
188
return -2 ;
189
189
}
190
190
if (len == 0 ) {
191
- fprintf (stderr , "File at '%s' is empty\n" , BINARY_FILE );
192
- return -3 ;
191
+ fprintf (stderr , "File at '%s' is empty\n" , BINARY_FILE );
192
+ return -3 ;
193
193
}
194
194
195
195
// Map memory.
196
196
mem_map_checked (uc , BASE_ADDRESS , len , UC_PROT_ALL );
197
- printf ("Len: %lx" , len );
197
+ printf ("Len: %lx\n " , len );
198
198
fflush (stdout );
199
199
200
200
// write machine code to be emulated to memory
@@ -209,7 +209,7 @@ int main(int argc, char **argv, char **envp) {
209
209
uint64_t start_address = CODE_ADDRESS ; // address of entry point of main()
210
210
uint64_t end_address = END_ADDRESS ; // Address of last instruction in main()
211
211
uc_reg_write (uc , UC_X86_REG_RIP , & start_address ); // address of entry point of main()
212
-
212
+
213
213
// Setup the Stack
214
214
mem_map_checked (uc , STACK_ADDRESS - STACK_SIZE , STACK_SIZE , UC_PROT_READ | UC_PROT_WRITE );
215
215
uint64_t stack_val = STACK_ADDRESS ;
@@ -219,7 +219,7 @@ int main(int argc, char **argv, char **envp) {
219
219
// reserve some space for our input data
220
220
mem_map_checked (uc , INPUT_LOCATION , INPUT_SIZE_MAX , UC_PROT_READ );
221
221
222
- // build a "dummy" argv with lenth 2 at 0x10000:
222
+ // build a "dummy" argv with lenth 2 at 0x10000:
223
223
// 0x10000 argv[0] NULL
224
224
// 0x10008 argv[1] (char *)0x10016 --. points to the next offset.
225
225
// 0x10016 argv[1][0], ... <-^ contains the acutal input data. (INPUT_LOCATION + INPUT_OFFSET)
@@ -264,6 +264,6 @@ int main(int argc, char **argv, char **envp) {
264
264
break ;
265
265
default :
266
266
break ;
267
- }
267
+ }
268
268
return 0 ;
269
269
}
0 commit comments