aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvanhauser-thc <vh@thc.org>2021-06-23 13:15:32 +0200
committervanhauser-thc <vh@thc.org>2021-06-23 13:15:32 +0200
commitd64cde8370dc6299b9280feaa575a4266163788f (patch)
tree73e245d12a70efad4b1b89215c12ef77810afd6f /src
parentc6b77d2d05b07040c6599d8c9a142f0ad96ced62 (diff)
downloadafl++-d64cde8370dc6299b9280feaa575a4266163788f.tar.gz
non-unix compat
Diffstat (limited to 'src')
-rw-r--r--src/afl-fuzz-init.c118
1 files changed, 61 insertions, 57 deletions
diff --git a/src/afl-fuzz-init.c b/src/afl-fuzz-init.c
index cc5974d8..5e4f1585 100644
--- a/src/afl-fuzz-init.c
+++ b/src/afl-fuzz-init.c
@@ -710,101 +710,105 @@ void read_testcases(afl_state_t *afl, u8 *directory) {
}
- i = nl_cnt;
- do {
+ if (nl_cnt) {
- --i;
+ i = nl_cnt;
+ do {
- struct stat st;
+ --i;
- u8 dfn[PATH_MAX];
- snprintf(dfn, PATH_MAX, "%s/.state/deterministic_done/%s", afl->in_dir,
- nl[i]->d_name);
- u8 *fn2 = alloc_printf("%s/%s", dir, nl[i]->d_name);
+ struct stat st;
+ u8 dfn[PATH_MAX];
+ snprintf(dfn, PATH_MAX, "%s/.state/deterministic_done/%s", afl->in_dir,
+ nl[i]->d_name);
+ u8 *fn2 = alloc_printf("%s/%s", dir, nl[i]->d_name);
- u8 passed_det = 0;
+ u8 passed_det = 0;
- if (lstat(fn2, &st) || access(fn2, R_OK)) {
+ if (lstat(fn2, &st) || access(fn2, R_OK)) {
- PFATAL("Unable to access '%s'", fn2);
+ PFATAL("Unable to access '%s'", fn2);
- }
+ }
- /* obviously we want to skip "descending" into . and .. directories,
- however it is a good idea to skip also directories that start with
- a dot */
- if (subdirs && S_ISDIR(st.st_mode) && nl[i]->d_name[0] != '.') {
+ /* obviously we want to skip "descending" into . and .. directories,
+ however it is a good idea to skip also directories that start with
+ a dot */
+ if (subdirs && S_ISDIR(st.st_mode) && nl[i]->d_name[0] != '.') {
- free(nl[i]); /* not tracked */
- read_testcases(afl, fn2);
- ck_free(fn2);
- continue;
+ free(nl[i]); /* not tracked */
+ read_testcases(afl, fn2);
+ ck_free(fn2);
+ continue;
- }
+ }
- free(nl[i]);
+ free(nl[i]);
- if (!S_ISREG(st.st_mode) || !st.st_size || strstr(fn2, "/README.txt")) {
+ if (!S_ISREG(st.st_mode) || !st.st_size || strstr(fn2, "/README.txt")) {
- ck_free(fn2);
- continue;
+ ck_free(fn2);
+ continue;
- }
+ }
- if (st.st_size > MAX_FILE) {
+ if (st.st_size > MAX_FILE) {
- WARNF("Test case '%s' is too big (%s, limit is %s), partial reading", fn2,
- stringify_mem_size(val_buf[0], sizeof(val_buf[0]), st.st_size),
- stringify_mem_size(val_buf[1], sizeof(val_buf[1]), MAX_FILE));
+ WARNF("Test case '%s' is too big (%s, limit is %s), partial reading",
+ fn2,
+ stringify_mem_size(val_buf[0], sizeof(val_buf[0]), st.st_size),
+ stringify_mem_size(val_buf[1], sizeof(val_buf[1]), MAX_FILE));
- }
+ }
- /* Check for metadata that indicates that deterministic fuzzing
- is complete for this entry. We don't want to repeat deterministic
- fuzzing when resuming aborted scans, because it would be pointless
- and probably very time-consuming. */
+ /* Check for metadata that indicates that deterministic fuzzing
+ is complete for this entry. We don't want to repeat deterministic
+ fuzzing when resuming aborted scans, because it would be pointless
+ and probably very time-consuming. */
- if (!access(dfn, F_OK)) { passed_det = 1; }
+ if (!access(dfn, F_OK)) { passed_det = 1; }
- add_to_queue(afl, fn2, st.st_size >= MAX_FILE ? MAX_FILE : st.st_size,
- passed_det);
+ add_to_queue(afl, fn2, st.st_size >= MAX_FILE ? MAX_FILE : st.st_size,
+ passed_det);
- if (unlikely(afl->shm.cmplog_mode)) {
+ if (unlikely(afl->shm.cmplog_mode)) {
- if (afl->cmplog_lvl == 1) {
+ if (afl->cmplog_lvl == 1) {
- if (!afl->cmplog_max_filesize ||
- afl->cmplog_max_filesize < st.st_size) {
+ if (!afl->cmplog_max_filesize ||
+ afl->cmplog_max_filesize < st.st_size) {
- afl->cmplog_max_filesize = st.st_size;
+ afl->cmplog_max_filesize = st.st_size;
- }
+ }
- } else if (afl->cmplog_lvl == 2) {
+ } else if (afl->cmplog_lvl == 2) {
- if (!afl->cmplog_max_filesize ||
- afl->cmplog_max_filesize > st.st_size) {
+ if (!afl->cmplog_max_filesize ||
+ afl->cmplog_max_filesize > st.st_size) {
- afl->cmplog_max_filesize = st.st_size;
+ afl->cmplog_max_filesize = st.st_size;
+
+ }
}
}
- }
+ /*
+ if (unlikely(afl->schedule >= FAST && afl->schedule <= RARE)) {
- /*
- if (unlikely(afl->schedule >= FAST && afl->schedule <= RARE)) {
+ u64 cksum = hash64(afl->fsrv.trace_bits, afl->fsrv.map_size,
+ HASH_CONST); afl->queue_top->n_fuzz_entry = cksum % N_FUZZ_SIZE;
+ afl->n_fuzz[afl->queue_top->n_fuzz_entry] = 1;
- u64 cksum = hash64(afl->fsrv.trace_bits, afl->fsrv.map_size,
- HASH_CONST); afl->queue_top->n_fuzz_entry = cksum % N_FUZZ_SIZE;
- afl->n_fuzz[afl->queue_top->n_fuzz_entry] = 1;
+ }
- }
+ */
- */
+ } while (i > 0);
- } while (i > 0);
+ }
free(nl); /* not tracked */