summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2022-02-23 08:00:00 +0000
committerDmitry V. Levin <ldv@altlinux.org>2022-02-24 09:20:44 +0000
commit7c660b5fd94dd9bec54f2bc6587a2425f69be9d6 (patch)
tree59c619e9f2fb99e1b70eeb323efe2c9ad92e814d
parentb95a6d48c9d4a6490ee8cf638098407ac482495a (diff)
downloadlinux-pam-git-ldv/pam_exec-strdup.tar.gz
pam_exec: remove redundant strdupldv/pam_exec-strdup
In the child process, the elements of argv[] are not modified, so there is no need to copy strings. * modules/pam_exec/pam_exec.c (call_exec): Do not call strdup on argv[] elements during arggv[] initialization. Resolves: https://github.com/linux-pam/linux-pam/pull/446
-rw-r--r--modules/pam_exec/pam_exec.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/modules/pam_exec/pam_exec.c b/modules/pam_exec/pam_exec.c
index 05dec167..3fd388a5 100644
--- a/modules/pam_exec/pam_exec.c
+++ b/modules/pam_exec/pam_exec.c
@@ -305,7 +305,7 @@ call_exec (const char *pam_type, pam_handle_t *pamh,
}
else /* child */
{
- char **arggv;
+ const char **arggv;
int i;
char **envlist, **tmp;
int envlen, nitems;
@@ -418,7 +418,7 @@ call_exec (const char *pam_type, pam_handle_t *pamh,
_exit (ENOMEM);
for (i = 0; i < (argc - optargc); i++)
- arggv[i] = strdup(argv[i+optargc]);
+ arggv[i] = argv[i+optargc];
arggv[i] = NULL;
/*
@@ -466,7 +466,9 @@ call_exec (const char *pam_type, pam_handle_t *pamh,
if (debug)
pam_syslog (pamh, LOG_DEBUG, "Calling %s ...", arggv[0]);
- execve (arggv[0], arggv, envlist);
+ DIAG_PUSH_IGNORE_CAST_QUAL;
+ execve (arggv[0], (char **) arggv, envlist);
+ DIAG_POP_IGNORE_CAST_QUAL;
i = errno;
pam_syslog (pamh, LOG_ERR, "execve(%s,...) failed: %m", arggv[0]);
free(envlist);