summaryrefslogtreecommitdiff
path: root/files.c
diff options
context:
space:
mode:
authorJagger <robert@swiecki.net>2016-09-25 16:19:45 +0200
committerJagger <robert@swiecki.net>2016-09-25 16:19:45 +0200
commit1b2d482cdbc8a22624ca91ae59c640374a244b96 (patch)
treee3781372637b533e1182631750d7f7d8c887cb59 /files.c
parent3c7e7ceb7051eec3b5579dc3385bb4ac2853a066 (diff)
downloadhonggfuzz-1b2d482cdbc8a22624ca91ae59c640374a244b96.tar.gz
Make coverage append the default mode
Diffstat (limited to 'files.c')
-rw-r--r--files.c37
1 files changed, 10 insertions, 27 deletions
diff --git a/files.c b/files.c
index 08d3cea5..75e7dd41 100644
--- a/files.c
+++ b/files.c
@@ -146,9 +146,9 @@ bool files_writePatternToFd(int fd, off_t size, unsigned char p)
static bool files_readdir(honggfuzz_t * hfuzz)
{
- DIR *dir = opendir(hfuzz->inputFile);
+ DIR *dir = opendir(hfuzz->inputDir);
if (!dir) {
- PLOG_W("Couldn't open dir '%s'", hfuzz->inputFile);
+ PLOG_W("Couldn't open dir '%s'", hfuzz->inputDir);
return false;
}
defer {
@@ -161,7 +161,7 @@ static bool files_readdir(honggfuzz_t * hfuzz)
errno = 0;
struct dirent *res = readdir(dir);
if (res == NULL && errno != 0) {
- PLOG_W("Couldn't read the '%s' dir", hfuzz->inputFile);
+ PLOG_W("Couldn't read the '%s' dir", hfuzz->inputDir);
return false;
}
@@ -170,7 +170,7 @@ static bool files_readdir(honggfuzz_t * hfuzz)
}
char path[PATH_MAX];
- snprintf(path, sizeof(path), "%s/%s", hfuzz->inputFile, res->d_name);
+ snprintf(path, sizeof(path), "%s/%s", hfuzz->inputDir, res->d_name);
struct stat st;
if (stat(path, &st) == -1) {
LOG_W("Couldn't stat() the '%s' file", path);
@@ -207,7 +207,7 @@ static bool files_readdir(honggfuzz_t * hfuzz)
}
if (count == 0) {
- LOG_W("Directory '%s' doesn't contain any regular files", hfuzz->inputFile);
+ LOG_W("Directory '%s' doesn't contain any regular files", hfuzz->inputDir);
return false;
}
@@ -232,14 +232,14 @@ bool files_init(honggfuzz_t * hfuzz)
return true;
}
- if (!hfuzz->inputFile) {
+ if (!hfuzz->inputDir) {
LOG_W("No input file/dir specified");
return false;
}
struct stat st;
- if (stat(hfuzz->inputFile, &st) == -1) {
- PLOG_W("Couldn't stat the input file/dir '%s'", hfuzz->inputFile);
+ if (stat(hfuzz->inputDir, &st) == -1) {
+ PLOG_W("Couldn't stat the input dir '%s'", hfuzz->inputDir);
return false;
}
@@ -247,25 +247,8 @@ bool files_init(honggfuzz_t * hfuzz)
return files_readdir(hfuzz);
}
- if (!S_ISREG(st.st_mode)) {
- LOG_W("'%s' is not a regular file, nor a directory", hfuzz->inputFile);
- return false;
- }
-
- if (hfuzz->maxFileSz && st.st_size > (off_t) hfuzz->maxFileSz) {
- LOG_W("File '%s' is bigger than maximal defined file size (-F): %" PRId64 " > %" PRId64,
- hfuzz->inputFile, (int64_t) st.st_size, (int64_t) hfuzz->maxFileSz);
- return false;
- }
-
- if (hfuzz->maxFileSz == 0UL) {
- hfuzz->maxFileSz = (size_t) st.st_size;
- LOG_I("Maximum corpus file size set to: %zu bytes", hfuzz->maxFileSz);
- }
-
- hfuzz->files[0] = hfuzz->inputFile;
- hfuzz->fileCnt = 1;
- return true;
+ LOG_W("The initial corpus directory '%s' is not a directory", hfuzz->inputDir);
+ return false;
}
const char *files_basename(char *path)