Skip to content

Commit

Permalink
Fix clang-tidy warnings, again
Browse files Browse the repository at this point in the history
  • Loading branch information
rgacogne committed Mar 18, 2024
1 parent b1564d4 commit 6e58535
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions pdns/dnspcap2protobuf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ try {

PcapPacketReader pr(argv[1]);

// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic): it's argv..
auto filePtr = pdns::openFileForWriting(argv[2], 0600, true, false);
if (!filePtr) {
auto error = errno;
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic): it's argv..
cerr<<"Error opening output file "<<argv[2]<<": "<<stringerror(error)<<endl;
exit(EXIT_FAILURE);
}
Expand Down
3 changes: 2 additions & 1 deletion pdns/libssl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,8 @@ static void libssl_key_log_file_callback(const SSL* ssl, const char* line)
return;
}

auto filePtr = reinterpret_cast<FILE*>(SSL_CTX_get_ex_data(sslCtx, s_keyLogIndex));
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast): OpenSSL's API
auto* filePtr = reinterpret_cast<FILE*>(SSL_CTX_get_ex_data(sslCtx, s_keyLogIndex));
if (filePtr == nullptr) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions pdns/misc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1789,14 +1789,14 @@ UniqueFilePtr openFileForWriting(const std::string& filePath, mode_t permissions
}
int fileDesc = open(filePath.c_str(), flags, permissions);

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This argument to a file access function is derived from
user input (a command-line argument)
and then passed to open(__file).
if (fileDesc == -1) {
return UniqueFilePtr(nullptr);
return {};
}
auto filePtr = pdns::UniqueFilePtr(fdopen(fileDesc, appendIfExists ? "a" : "w"));
if (!filePtr) {
auto error = errno;
close(fileDesc);
errno = error;
return UniqueFilePtr(nullptr);
return {};
}
return filePtr;
}
Expand Down

0 comments on commit 6e58535

Please sign in to comment.