summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.clang-tidy1
-rw-r--r--include/pam_authenticate.hpp13
-rw-r--r--include/ssl_key_handler.hpp2
-rw-r--r--redfish-core/lib/virtual_media.hpp1
4 files changed, 13 insertions, 4 deletions
diff --git a/.clang-tidy b/.clang-tidy
index 85fc555ac5..462c5bf4af 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -206,6 +206,7 @@ cppcoreguidelines-interfaces-global-init,
cppcoreguidelines-macro-usage,
cppcoreguidelines-pro-bounds-array-to-pointer-decay,
cppcoreguidelines-pro-bounds-pointer-arithmetic,
+cppcoreguidelines-pro-type-const-cast,
cppcoreguidelines-pro-type-member-init,
cppcoreguidelines-pro-type-reinterpret-cast,
cppcoreguidelines-special-member-functions,
diff --git a/include/pam_authenticate.hpp b/include/pam_authenticate.hpp
index 1459ea6112..10d9116156 100644
--- a/include/pam_authenticate.hpp
+++ b/include/pam_authenticate.hpp
@@ -86,8 +86,11 @@ inline int pamAuthenticateUser(const std::string_view username,
{
std::string userStr(username);
std::string passStr(password);
- const struct pam_conv localConversation = {
- pamFunctionConversation, const_cast<char*>(passStr.c_str())};
+
+ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
+ char* passStrNoConst = const_cast<char*>(passStr.c_str());
+ const struct pam_conv localConversation = {pamFunctionConversation,
+ passStrNoConst};
pam_handle_t* localAuthHandle = nullptr; // this gets set by pam_start
int retval = pam_start("webserver", userStr.c_str(), &localConversation,
@@ -119,8 +122,10 @@ inline int pamAuthenticateUser(const std::string_view username,
inline int pamUpdatePassword(const std::string& username,
const std::string& password)
{
- const struct pam_conv localConversation = {
- pamFunctionConversation, const_cast<char*>(password.c_str())};
+ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
+ char* passStrNoConst = const_cast<char*>(password.c_str());
+ const struct pam_conv localConversation = {pamFunctionConversation,
+ passStrNoConst};
pam_handle_t* localAuthHandle = nullptr; // this gets set by pam_start
int retval = pam_start("webserver", username.c_str(), &localConversation,
diff --git a/include/ssl_key_handler.hpp b/include/ssl_key_handler.hpp
index dbe596a586..fcb79f24f6 100644
--- a/include/ssl_key_handler.hpp
+++ b/include/ssl_key_handler.hpp
@@ -232,6 +232,8 @@ inline int addExt(X509* cert, int nid, const char* value)
X509_EXTENSION* ex = nullptr;
X509V3_CTX ctx{};
X509V3_set_ctx(&ctx, cert, cert, nullptr, nullptr, 0);
+
+ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
ex = X509V3_EXT_conf_nid(nullptr, &ctx, nid, const_cast<char*>(value));
if (!ex)
{
diff --git a/redfish-core/lib/virtual_media.hpp b/redfish-core/lib/virtual_media.hpp
index 00c3ecf5ae..f617f4a98f 100644
--- a/redfish-core/lib/virtual_media.hpp
+++ b/redfish-core/lib/virtual_media.hpp
@@ -501,6 +501,7 @@ inline bool
template <typename T>
static void secureCleanup(T& value)
{
+ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
auto raw = const_cast<typename T::value_type*>(value.data());
explicit_bzero(raw, value.size() * sizeof(*raw));
}