summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2022-01-07 20:40:43 +0300
committerEd Tanous <ed@tanous.net>2022-01-12 22:00:37 +0300
commitfcc5aa66f2dca9f33c70df8dcd828ac4f31d7a92 (patch)
tree2774efcc0ef853345648297b2c9df407987d0453
parent49d1eeaab4085cd0284ee041f4775aaa982074c6 (diff)
downloadbmcweb-fcc5aa66f2dca9f33c70df8dcd828ac4f31d7a92.tar.xz
Enable malloc checks
We only use malloc in one place, when we hand a pointer off to PAM. Ignore that one issue, and enable the check. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I37c41c193bae1bab370b03944617c642df0179fc
-rw-r--r--.clang-tidy1
-rw-r--r--include/pam_authenticate.hpp2
2 files changed, 3 insertions, 0 deletions
diff --git a/.clang-tidy b/.clang-tidy
index b708a70881..c15af94606 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -204,6 +204,7 @@ clang-analyzer-webkit.RefCntblBaseVirtualDtor,
cppcoreguidelines-init-variables,
cppcoreguidelines-interfaces-global-init,
cppcoreguidelines-macro-usage,
+cppcoreguidelines-no-malloc,
cppcoreguidelines-pro-bounds-array-to-pointer-decay,
cppcoreguidelines-pro-bounds-pointer-arithmetic,
cppcoreguidelines-pro-type-const-cast,
diff --git a/include/pam_authenticate.hpp b/include/pam_authenticate.hpp
index 10d9116156..ca8c8d3250 100644
--- a/include/pam_authenticate.hpp
+++ b/include/pam_authenticate.hpp
@@ -57,9 +57,11 @@ inline int pamFunctionConversation(int numMsg, const struct pam_message** msg,
std::strncpy(pass, appPass, appPassSize + 1);
size_t numMsgSize = static_cast<size_t>(numMsg);
+ // NOLINTNEXTLINE(cppcoreguidelines-no-malloc)
void* ptr = calloc(numMsgSize, sizeof(struct pam_response));
if (ptr == nullptr)
{
+ // NOLINTNEXTLINE(cppcoreguidelines-no-malloc)
free(pass);
return PAM_BUF_ERR;
}