aboutsummaryrefslogtreecommitdiff
path: root/modules/pam_unix/support.c
diff options
context:
space:
mode:
authorTobias Stoeckmann <tobias@stoeckmann.org>2023-12-15 10:14:11 +0100
committerDmitry V. Levin <ldv@strace.io>2023-12-19 12:22:59 +0000
commit2e375aad04d047e12468f93300ad7e42a8a03ff3 (patch)
tree29f31fa0bf4700476eccd4a307ef6638d9707851 /modules/pam_unix/support.c
parentc2fafe1be0fb72aa1bd521efe2f524074bf143c7 (diff)
downloadpam-2e375aad04d047e12468f93300ad7e42a8a03ff3.tar.gz
pam-2e375aad04d047e12468f93300ad7e42a8a03ff3.tar.bz2
pam-2e375aad04d047e12468f93300ad7e42a8a03ff3.zip
treewide: use asprintf to construct strings
The asprintf function is considered as given for current code already. Use it instead of calling malloc + strcpy + strcat manually. Reported-by: Benny Baumann <BenBE@geshi.org> Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Diffstat (limited to 'modules/pam_unix/support.c')
-rw-r--r--modules/pam_unix/support.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/modules/pam_unix/support.c b/modules/pam_unix/support.c
index 9d8cac7d..49807873 100644
--- a/modules/pam_unix/support.c
+++ b/modules/pam_unix/support.c
@@ -722,12 +722,9 @@ int _unix_verify_password(pam_handle_t * pamh, const char *name
retval = get_pwd_hash(pamh, name, &pwd, &salt);
- data_name = malloc(sizeof(FAIL_PREFIX) + strlen(name));
- if (data_name == NULL) {
+ if (asprintf(&data_name, "%s%s", FAIL_PREFIX, name) < 0) {
pam_syslog(pamh, LOG_CRIT, "no memory for data-name");
- } else {
- strcpy(data_name, FAIL_PREFIX);
- strcpy(data_name + sizeof(FAIL_PREFIX) - 1, name);
+ data_name = NULL;
}
if (p != NULL && strlen(p) > PAM_MAX_RESP_SIZE) {