Skip to content

Commit 2fca135

Browse files
committed
fuzzer: add PID to temp file names.
1 parent ed29df0 commit 2fca135

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

fuzz/tivars_file_fuzzer.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
#include <string>
99
#include <system_error>
1010

11+
#ifdef _WIN32
12+
#include <process.h>
13+
#else
14+
#include <unistd.h>
15+
#endif
16+
1117
#include "../src/TIFlashFile.h"
1218
#include "../src/TIModels.h"
1319
#include "../src/TIVarFile.h"
@@ -27,6 +33,15 @@ namespace
2733
std::once_flag initFlag;
2834
std::atomic<uint64_t> inputCounter{0};
2935

36+
int current_process_id()
37+
{
38+
#ifdef _WIN32
39+
return _getpid();
40+
#else
41+
return getpid();
42+
#endif
43+
}
44+
3045
void init_library()
3146
{
3247
std::call_once(initFlag, []()
@@ -48,7 +63,7 @@ namespace
4863
}
4964

5065
const uint64_t uniqueId = inputCounter.fetch_add(1, std::memory_order_relaxed);
51-
const std::filesystem::path path = tempDir / ("tivars-fuzz-" + std::to_string(uniqueId) + ".bin");
66+
const std::filesystem::path path = tempDir / ("tivars-fuzz-" + std::to_string(current_process_id()) + "-" + std::to_string(uniqueId) + ".bin");
5267
std::ofstream out(path, std::ios::binary);
5368
out.write(reinterpret_cast<const char*>(data), static_cast<std::streamsize>(size));
5469
out.close();

0 commit comments

Comments
 (0)