Swap strcpy for strncpy
strncpy has range checks, which reduce the possibility of overrunning
the buffer in the case of a bug.
Tested: clang-tidy cert check now passes. Needs functional testing.
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
Change-Id: I2fab19ca40f97cc0574146883ee19b573285a59c
diff --git a/include/pam_authenticate.hpp b/include/pam_authenticate.hpp
index 59c8cd6..f2c7356 100644
--- a/include/pam_authenticate.hpp
+++ b/include/pam_authenticate.hpp
@@ -23,7 +23,7 @@
return PAM_AUTH_ERR;
}
- std::strcpy(pass, appPass);
+ std::strncpy(pass, appPass, appPassSize + 1);
*resp = reinterpret_cast<pam_response*>(
calloc(static_cast<size_t>(numMsg), sizeof(struct pam_response)));