diff options
author | Dmitry V. Levin <ldv@strace.io> | 2024-12-30 08:00:00 +0000 |
---|---|---|
committer | Dmitry V. Levin <ldv@strace.io> | 2024-12-30 08:00:00 +0000 |
commit | e634a3a9be9484ada6e93970dfaf0f055ca17332 (patch) | |
tree | 18ed0f317b95dd08c94f98569fd1d27d7b9f5745 /modules/pam_unix/bigcrypt.c | |
parent | c6efd4e8696233c8c180a10dbcbcb035e1bd8536 (diff) | |
download | pam-e634a3a9be9484ada6e93970dfaf0f055ca17332.tar.gz pam-e634a3a9be9484ada6e93970dfaf0f055ca17332.tar.bz2 pam-e634a3a9be9484ada6e93970dfaf0f055ca17332.zip |
pam_unix: do not overwrite the string returned by crypt_r
Given that the crypt_data storage passed to crypt_r is cleared
afterwards, there is no point in clearing the string returned by
crypt_r. This also fixes the issue with those crypt_r implementations
that can return a pointer to read-only memory.
Resolves: https://github.com/linux-pam/linux-pam/issues/866
Diffstat (limited to 'modules/pam_unix/bigcrypt.c')
-rw-r--r-- | modules/pam_unix/bigcrypt.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/modules/pam_unix/bigcrypt.c b/modules/pam_unix/bigcrypt.c index 296e01f7..f960d978 100644 --- a/modules/pam_unix/bigcrypt.c +++ b/modules/pam_unix/bigcrypt.c @@ -116,7 +116,9 @@ char *bigcrypt(const char *key, const char *salt) } /* and place in the static area */ strncpy(cipher_ptr, tmp_ptr, 13); +#ifndef HAVE_CRYPT_R pam_overwrite_string(tmp_ptr); +#endif cipher_ptr += ESEGMENT_SIZE + SALT_SIZE; plaintext_ptr += SEGMENT_SIZE; /* first block of SEGMENT_SIZE */ @@ -149,7 +151,9 @@ char *bigcrypt(const char *key, const char *salt) /* skip the salt for seg!=0 */ strncpy(cipher_ptr, (tmp_ptr + SALT_SIZE), ESEGMENT_SIZE); +#ifndef HAVE_CRYPT_R pam_overwrite_string(tmp_ptr); +#endif cipher_ptr += ESEGMENT_SIZE; plaintext_ptr += SEGMENT_SIZE; |