From 2faf6dfc3416dcae393f17c35cd0ca31868f204f Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Wed, 3 Jan 2024 19:51:06 +0100 Subject: 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 --- modules/pam_env/pam_env.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'modules/pam_env') 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); /* -- cgit v1.2.3