Skip to content

Commit

Permalink
Merge pull request #2712 from matt335672/v0_9_allow_long_strings_in_p…
Browse files Browse the repository at this point in the history
…am_env

[0.9] Remove size limit for PAM environment variables
  • Loading branch information
matt335672 authored Jun 1, 2023
2 parents f1fa6bb + 3d2b3b8 commit 27ea401
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions sesman/verify_user_pam.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down

0 comments on commit 27ea401

Please sign in to comment.