Coverity CIDs 468127 468134 468148

These Coverity warnings all relate to the user of g_setenv() where the
return result isn't checked.

An additional void function g_setenv_log() is provided which logs
failures to set environment variables, and returns no status. This is
used in all the places where g_setenv_is currently called.
This commit is contained in:
matt335672
2025-04-17 14:36:25 +01:00
parent f2dd3fb3dc
commit 417076b215
7 changed files with 55 additions and 31 deletions
+4 -4
View File
@@ -528,12 +528,12 @@ auth_set_env(struct auth_info *auth_info)
for (pam_env = pam_envlist; *pam_env != NULL; ++pam_env)
{
char *str = *pam_env;
int eq_pos = g_pos(str, "=");
char *eq_pos = strchr(str, '=');
if (eq_pos > 0)
if (eq_pos != NULL)
{
str[eq_pos] = '\0';
g_setenv(str, str + eq_pos + 1, 1);
*eq_pos = '\0';
g_setenv_log(str, eq_pos + 1, 1);
}
g_free(str);