diff options
author | Tobias Stoeckmann <tobias@stoeckmann.org> | 2024-01-03 19:51:06 +0100 |
---|---|---|
committer | Dmitry V. Levin <ldv@strace.io> | 2024-01-05 23:36:44 +0000 |
commit | 2faf6dfc3416dcae393f17c35cd0ca31868f204f (patch) | |
tree | 99b6b3a410f35daa9aa2317765d363fb6ffcbe80 /modules | |
parent | 2aab29274cadd5d8c55a78b30d77bb51630a2494 (diff) | |
download | pam-2faf6dfc3416dcae393f17c35cd0ca31868f204f.tar.gz pam-2faf6dfc3416dcae393f17c35cd0ca31868f204f.tar.bz2 pam-2faf6dfc3416dcae393f17c35cd0ca31868f204f.zip |
pam_env: skip _expand_arg if possible
If no special characters exist, simply skip _expand_arg to avoid
memory allocations and string copying.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/pam_env/pam_env.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/modules/pam_env/pam_env.c b/modules/pam_env/pam_env.c index 592bc4b8..b4cb5477 100644 --- a/modules/pam_env/pam_env.c +++ b/modules/pam_env/pam_env.c @@ -673,6 +673,13 @@ _expand_arg(pam_handle_t *pamh, char **value) const char *orig=*value; struct string_buffer buf; + /* + * Return early if there are no special characters present in the value. + */ + if ((*value)[strcspn(*value, "\\$@")] == '\0') { + return PAM_SUCCESS; + } + _strbuf_init(&buf); /* |