aboutsummaryrefslogtreecommitdiff
path: root/libpam
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
commitc2fafe1be0fb72aa1bd521efe2f524074bf143c7 (patch)
tree0790beda071109b1c0ef9397d442ff641f7077c9 /libpam
parent6834e0dd1dcae917caa464d1fe124c2f6c6116f4 (diff)
downloadpam-c2fafe1be0fb72aa1bd521efe2f524074bf143c7.tar.gz
pam-c2fafe1be0fb72aa1bd521efe2f524074bf143c7.tar.bz2
pam-c2fafe1be0fb72aa1bd521efe2f524074bf143c7.zip
treewide: replace malloc followed by strcpy with strdup
Suggested-by: Benny Baumann <BenBE@geshi.org> Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Diffstat (limited to 'libpam')
-rw-r--r--libpam/pam_misc.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/libpam/pam_misc.c b/libpam/pam_misc.c
index a843ebc7..721b36f3 100644
--- a/libpam/pam_misc.c
+++ b/libpam/pam_misc.c
@@ -116,14 +116,8 @@ char *_pam_strdup(const char *x)
register char *new=NULL;
if (x != NULL) {
- register size_t len;
-
- len = strlen (x) + 1; /* length of string including NUL */
- if ((new = malloc(len)) == NULL) {
- len = 0;
+ if ((new = strdup(x)) == NULL) {
pam_syslog(NULL, LOG_CRIT, "_pam_strdup: failed to get memory");
- } else {
- strcpy (new, x);
}
x = NULL;
}