aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Baumann <BenBE@geshi.org>2023-12-12 13:10:59 +0100
committerDmitry V. Levin <ldv@strace.io>2023-12-19 12:22:59 +0000
commitde910eeee54c1f38e9f8e83d8cd9c048f65051eb (patch)
tree14145b434676794161697b29dded8e774fd38b51
parentebc35c605beca9020bb743134575fdc558dfdaf5 (diff)
downloadpam-de910eeee54c1f38e9f8e83d8cd9c048f65051eb.tar.gz
pam-de910eeee54c1f38e9f8e83d8cd9c048f65051eb.tar.bz2
pam-de910eeee54c1f38e9f8e83d8cd9c048f65051eb.zip
pam_timestamp: ensure we get zero-initialized memory
This ensures that the whole buffer is in a somewhat defined state all the time even when some function calls write into the buffer only partially. This is not strictly necessary, as short writes into the buffer are checked, but it's good practice anyway. * modules/pam_timestamp/hmac_openssl_wrapper.c (generate_key): Replace malloc with calloc.
-rw-r--r--modules/pam_timestamp/hmac_openssl_wrapper.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/modules/pam_timestamp/hmac_openssl_wrapper.c b/modules/pam_timestamp/hmac_openssl_wrapper.c
index 2f015c6a..9926bbac 100644
--- a/modules/pam_timestamp/hmac_openssl_wrapper.c
+++ b/modules/pam_timestamp/hmac_openssl_wrapper.c
@@ -87,7 +87,7 @@ generate_key(pam_handle_t *pamh, char **key, size_t key_size)
ssize_t bytes_read = 0;
char *tmp = *key = NULL;
- tmp = malloc(key_size);
+ tmp = calloc(1, key_size);
if (!tmp) {
pam_syslog(pamh, LOG_CRIT, "Not enough memory");
return PAM_AUTH_ERR;
@@ -141,7 +141,7 @@ read_file(pam_handle_t *pamh, int fd, char **text, size_t *text_length)
return PAM_AUTH_ERR;
}
- tmp = malloc(st.st_size);
+ tmp = calloc(1, st.st_size);
if (!tmp) {
pam_syslog(pamh, LOG_CRIT, "Not enough memory");
close(fd);