From 546dd336d15251981bb8bcb30c159d0a39bb387e Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sun, 19 Dec 2021 21:20:54 -0600 Subject: [PATCH] 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. --- pam/pam.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- 2.39.5