Skip to content

Commit

Permalink
Create shm file in the working dir
Browse files Browse the repository at this point in the history
  • Loading branch information
robertswiecki committed Sep 7, 2016
1 parent 919cf2b commit 5b81a50
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions files.c
Expand Up @@ -489,9 +489,10 @@ uint8_t *files_mapFileShared(char *fileName, off_t * fileSz, int *fd)
return buf;
}

void *files_mapSharedMem(size_t sz, int *fd)
void *files_mapSharedMem(size_t sz, int *fd, const char *dir)
{
char template[] = "/tmp/hfuzz.XXXXXX";
char template[PATH_MAX];
snprintf(template, sizeof(template), "%s/hfuzz.XXXXXX", dir);
if ((*fd = mkstemp(template)) == -1) {
PLOG_W("mkstemp('%s')", template);
return MAP_FAILED;
Expand Down
2 changes: 1 addition & 1 deletion files.h
Expand Up @@ -56,7 +56,7 @@ extern uint8_t *files_mapFile(char *fileName, off_t * fileSz, int *fd, bool isWr

extern uint8_t *files_mapFileShared(char *fileName, off_t * fileSz, int *fd);

extern void *files_mapSharedMem(size_t sz, int *fd);
extern void *files_mapSharedMem(size_t sz, int *fd, const char *dir);

extern bool files_readPidFromFile(const char *fileName, pid_t * pidPtr);

Expand Down
4 changes: 2 additions & 2 deletions honggfuzz.c
Expand Up @@ -150,9 +150,9 @@ int main(int argc, char **argv)
}

if (hfuzz.dynFileMethod != _HF_DYNFILE_NONE) {
hfuzz.feedback = files_mapSharedMem(sizeof(feedback_t), &hfuzz.bbFd);
hfuzz.feedback = files_mapSharedMem(sizeof(feedback_t), &hfuzz.bbFd, hfuzz.workDir);
if (hfuzz.feedback == MAP_FAILED) {
LOG_F("files_mapSharedMem(sz=%zu) failed", sizeof(feedback_t));
LOG_F("files_mapSharedMem(sz=%zu, dir='%s') failed", sizeof(feedback_t), hfuzz.workDir);
}
}

Expand Down

0 comments on commit 5b81a50

Please sign in to comment.