From 3d2b3b89f4975c12941000511ab209f368e70844 Mon Sep 17 00:00:00 2001 From: matt335672 <30179339+matt335672@users.noreply.github.com> Date: Wed, 31 May 2023 16:30:58 +0100 Subject: [PATCH] Remove size limit for PAM environment variables The current logic in auth_set_env() for PAM environments only allows environment variables to be around 256 characters in length. --- sesman/verify_user_pam.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/sesman/verify_user_pam.c b/sesman/verify_user_pam.c index 76310d578..a34d83cd7 100644 --- a/sesman/verify_user_pam.c +++ b/sesman/verify_user_pam.c @@ -419,9 +419,6 @@ auth_set_env(long in_val) struct t_auth_info *auth_info; char **pam_envlist; char **pam_env; - char item[256]; - char value[256]; - int eq_pos; auth_info = (struct t_auth_info *)in_val; @@ -434,16 +431,16 @@ auth_set_env(long in_val) { for (pam_env = pam_envlist; *pam_env != NULL; ++pam_env) { - eq_pos = g_pos(*pam_env, "="); + char *str = *pam_env; + int eq_pos = g_pos(str, "="); - if (eq_pos >= 0 && eq_pos < 250) + if (eq_pos > 0) { - g_strncpy(item, *pam_env, eq_pos); - g_strncpy(value, (*pam_env) + eq_pos + 1, 255); - g_setenv(item, value, 1); + str[eq_pos] = '\0'; + g_setenv(str, str + eq_pos + 1, 1); } - g_free(*pam_env); + g_free(str); } g_free(pam_envlist);