aboutsummaryrefslogtreecommitdiff
path: root/pam
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2021-12-19 21:20:54 -0600
committerEric Biggers <ebiggers@google.com>2021-12-19 21:43:34 -0600
commit546dd336d15251981bb8bcb30c159d0a39bb387e (patch)
tree12fd2292652b5ccc8e31ff82773b6a8b5213b1ae /pam
parent360467d0df626d2d0eac003a0a210814910804ce (diff)
pam: avoid compiler warning in copyIntoSecret()
gcc 11 enabled -Wmaybe-uninitialized by default. It causes a false-positive warning in copyIntoSecret() because gcc doesn't understand that mlock() is special and doesn't read from the memory. Just initialize the memory to avoid this warning.
Diffstat (limited to 'pam')
-rw-r--r--pam/pam.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/pam/pam.c b/pam/pam.c
index 1859a2f..1479dfa 100644
--- a/pam/pam.c
+++ b/pam/pam.c
@@ -93,7 +93,7 @@ void freeArray(pam_handle_t* pamh, void** array, int error_status) {
void* copyIntoSecret(void* data) {
size_t size = strlen(data) + 1; // include null terminator
- void* copy = malloc(size);
+ void* copy = calloc(1, size); // initialize to avoid a compiler warning
mlock(copy, size);
memcpy(copy, data, size);
return copy;