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
diff --git a/.clang-tidy b/.clang-tidy
index b708a70..c15af94 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -204,6 +204,7 @@
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 10d9116..ca8c8d3 100644
--- a/include/pam_authenticate.hpp
+++ b/include/pam_authenticate.hpp
@@ -57,9 +57,11 @@
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;
}