Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid usage of deprecated tmpnam function #158

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion autotest/autotest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,10 +557,18 @@ class pcap_expectation
std::vector<u_char> buffer;
};

static std::string
generate_temp_filepath(const std::filesystem::path& dir = std::filesystem::temp_directory_path())
{
auto time = std::chrono::system_clock::now().time_since_epoch().count();
std::string filename = "file" + std::to_string(time);
return dir / filename;
}

void tAutotest::recvThread(std::string interfaceName,
std::vector<std::string> expectFilePaths)
{
PcapDumper pcapDumper(std::tmpnam(nullptr) + std::string(".pcap"));
PcapDumper pcapDumper(generate_temp_filepath() + ".pcap");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to use mkstemp here because we may to run test in parallel and the code above is not concurrent safe.


std::vector<pcap_expectation> expect_pcaps;
for (const auto& expectFilePath : expectFilePaths)
Expand Down
Loading