mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-14 11:08:06 +00:00
non-unix compat
This commit is contained in:
@ -710,101 +710,105 @@ void read_testcases(afl_state_t *afl, u8 *directory) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
i = nl_cnt;
|
if (nl_cnt) {
|
||||||
do {
|
|
||||||
|
|
||||||
--i;
|
i = nl_cnt;
|
||||||
|
do {
|
||||||
|
|
||||||
struct stat st;
|
--i;
|
||||||
|
|
||||||
u8 dfn[PATH_MAX];
|
struct stat st;
|
||||||
snprintf(dfn, PATH_MAX, "%s/.state/deterministic_done/%s", afl->in_dir,
|
u8 dfn[PATH_MAX];
|
||||||
nl[i]->d_name);
|
snprintf(dfn, PATH_MAX, "%s/.state/deterministic_done/%s", afl->in_dir,
|
||||||
u8 *fn2 = alloc_printf("%s/%s", dir, nl[i]->d_name);
|
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,
|
/* obviously we want to skip "descending" into . and .. directories,
|
||||||
however it is a good idea to skip also directories that start with
|
however it is a good idea to skip also directories that start with
|
||||||
a dot */
|
a dot */
|
||||||
if (subdirs && S_ISDIR(st.st_mode) && nl[i]->d_name[0] != '.') {
|
if (subdirs && S_ISDIR(st.st_mode) && nl[i]->d_name[0] != '.') {
|
||||||
|
|
||||||
free(nl[i]); /* not tracked */
|
free(nl[i]); /* not tracked */
|
||||||
read_testcases(afl, fn2);
|
read_testcases(afl, fn2);
|
||||||
ck_free(fn2);
|
ck_free(fn2);
|
||||||
continue;
|
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);
|
ck_free(fn2);
|
||||||
continue;
|
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,
|
WARNF("Test case '%s' is too big (%s, limit is %s), partial reading",
|
||||||
stringify_mem_size(val_buf[0], sizeof(val_buf[0]), st.st_size),
|
fn2,
|
||||||
stringify_mem_size(val_buf[1], sizeof(val_buf[1]), MAX_FILE));
|
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
|
/* Check for metadata that indicates that deterministic fuzzing
|
||||||
is complete for this entry. We don't want to repeat deterministic
|
is complete for this entry. We don't want to repeat deterministic
|
||||||
fuzzing when resuming aborted scans, because it would be pointless
|
fuzzing when resuming aborted scans, because it would be pointless
|
||||||
and probably very time-consuming. */
|
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,
|
add_to_queue(afl, fn2, st.st_size >= MAX_FILE ? MAX_FILE : st.st_size,
|
||||||
passed_det);
|
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 ||
|
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;
|
afl->cmplog_max_filesize = st.st_size;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (afl->cmplog_lvl == 2) {
|
} else if (afl->cmplog_lvl == 2) {
|
||||||
|
|
||||||
if (!afl->cmplog_max_filesize ||
|
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;
|
afl->cmplog_max_filesize = st.st_size;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
/*
|
||||||
|
if (unlikely(afl->schedule >= FAST && afl->schedule <= RARE)) {
|
||||||
|
|
||||||
/*
|
u64 cksum = hash64(afl->fsrv.trace_bits, afl->fsrv.map_size,
|
||||||
if (unlikely(afl->schedule >= FAST && afl->schedule <= RARE)) {
|
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 */
|
free(nl); /* not tracked */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user