Skip to content

Commit 62306f5

Browse files
committed
minor fixes
1 parent ee14785 commit 62306f5

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

src/afl-fuzz.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ int main(int argc, char **argv_orig, char **envp) {
842842

843843
}
844844

845-
/* randamsa_init installs some signal hadlers, call it before
845+
/* radamsa_init installs some signal handlers, call it before
846846
setup_signal_handlers so that AFL++ can then replace those signal
847847
handlers */
848848
radamsa_init_ptr();
@@ -1390,7 +1390,7 @@ int main(int argc, char **argv_orig, char **envp) {
13901390
if (afl->shm_fuzz) {
13911391

13921392
afl_shm_deinit(afl->shm_fuzz);
1393-
free(afl->shm_fuzz);
1393+
ck_free(afl->shm_fuzz);
13941394

13951395
}
13961396

unicorn_mode/samples/c/harness.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ int main(int argc, char **argv, char **envp) {
184184

185185
// Map memory.
186186
mem_map_checked(uc, BASE_ADDRESS, len, UC_PROT_ALL);
187-
printf("Len: %lx", len);
187+
printf("Len: %lx\n", len);
188188
fflush(stdout);
189189

190190
// write machine code to be emulated to memory

unicorn_mode/samples/persistent/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ harness: harness.o
4444
${MYCC} -L${LIBDIR} harness.o ../../unicornafl/libunicornafl.a $(LDFLAGS) -o $@
4545

4646
debug: harness-debug.o
47-
${MYCC} -L${LIBDIR} harness.o ../../unicornafl/libunicornafl.a $(LDFLAGS) -o harness-debug
47+
${MYCC} -L${LIBDIR} harness-debug.o ../../unicornafl/libunicornafl.a $(LDFLAGS) -o harness-debug
4848

4949
fuzz: harness
5050
../../../afl-fuzz -m none -i sample_inputs -o out -- ./harness @@

unicorn_mode/samples/persistent/harness.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static void hook_code(uc_engine *uc, uint64_t address, uint32_t size, void *user
6868

6969
/*
7070
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.
7272
It will be a lot faster than an actual strlen for this specific purpose.
7373
*/
7474
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
8686
static uint64_t pad(uint64_t size) {
8787
if (size % ALIGNMENT == 0) return size;
8888
return ((size / ALIGNMENT) + 1) * ALIGNMENT;
89-
}
89+
}
9090

9191
/* returns the filesize in bytes, -1 or error. */
9292
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) {
100100

101101
off_t in_len = st.st_size;
102102
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;
106106
}
107107

108108
*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) {
117117

118118
/* Place the input at the right spot inside unicorn */
119119
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,
124124
void *data
125125
){
126126
// printf("Placing input with len %ld to %x\n", input_len, DATA_ADDRESS);
@@ -134,7 +134,7 @@ static bool place_input_callback(
134134
// Set up the function parameters accordingly RSI, RDI (see calling convention/disassembly)
135135
uc_reg_write(uc, UC_X86_REG_RSI, &INPUT_LOCATION); // argv
136136
uc_reg_write(uc, UC_X86_REG_RDI, &EMULATED_ARGC); // argc == 2
137-
137+
138138
// We need a valid c string, make sure it never goes out of bounds.
139139
input[input_len-1] = '\0';
140140
// Write the testcase to unicorn.
@@ -188,13 +188,13 @@ int main(int argc, char **argv, char **envp) {
188188
return -2;
189189
}
190190
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;
193193
}
194194

195195
// Map memory.
196196
mem_map_checked(uc, BASE_ADDRESS, len, UC_PROT_ALL);
197-
printf("Len: %lx", len);
197+
printf("Len: %lx\n", len);
198198
fflush(stdout);
199199

200200
// write machine code to be emulated to memory
@@ -209,7 +209,7 @@ int main(int argc, char **argv, char **envp) {
209209
uint64_t start_address = CODE_ADDRESS; // address of entry point of main()
210210
uint64_t end_address = END_ADDRESS; // Address of last instruction in main()
211211
uc_reg_write(uc, UC_X86_REG_RIP, &start_address); // address of entry point of main()
212-
212+
213213
// Setup the Stack
214214
mem_map_checked(uc, STACK_ADDRESS - STACK_SIZE, STACK_SIZE, UC_PROT_READ | UC_PROT_WRITE);
215215
uint64_t stack_val = STACK_ADDRESS;
@@ -219,7 +219,7 @@ int main(int argc, char **argv, char **envp) {
219219
// reserve some space for our input data
220220
mem_map_checked(uc, INPUT_LOCATION, INPUT_SIZE_MAX, UC_PROT_READ);
221221

222-
// build a "dummy" argv with lenth 2 at 0x10000:
222+
// build a "dummy" argv with lenth 2 at 0x10000:
223223
// 0x10000 argv[0] NULL
224224
// 0x10008 argv[1] (char *)0x10016 --. points to the next offset.
225225
// 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) {
264264
break;
265265
default:
266266
break;
267-
}
267+
}
268268
return 0;
269269
}

0 commit comments

Comments
 (0)