View | Details | Raw Unified | Return to bug 1346
Collapse All | Expand All

(-)/tmp/8kgIBOGGyc/openssh-4.6p1/session.c (-5 / +19 lines)
Lines 819-829 Link Here
819
819
820
/*
820
/*
821
 * Sets the value of the given variable in the environment.  If the variable
821
 * Sets the value of the given variable in the environment.  If the variable
822
 * already exists, its value is overriden.
822
 * already exists, its value is kept/overriden according to clobber.
823
 */
823
 */
824
void
824
void
825
child_set_env(char ***envp, u_int *envsizep, const char *name,
825
child_set_env_safe(char ***envp, u_int *envsizep, const char *name,
826
	const char *value)
826
	const char *value, char clobber)
827
{
827
{
828
	char **env;
828
	char **env;
829
	u_int envsize;
829
	u_int envsize;
Lines 849-855 Link Here
849
	for (i = 0; env[i]; i++)
849
	for (i = 0; env[i]; i++)
850
		if (strncmp(env[i], name, namelen) == 0 && env[i][namelen] == '=')
850
		if (strncmp(env[i], name, namelen) == 0 && env[i][namelen] == '=')
851
			break;
851
			break;
852
	if (env[i]) {
852
	if (env[i] && !clobber) {
853
		/* No use for this variable: already exists and no clobber */
854
		return;
855
	} else if (env[i] && clobber) {
853
		/* Reuse the slot. */
856
		/* Reuse the slot. */
854
		xfree(env[i]);
857
		xfree(env[i]);
855
	} else {
858
	} else {
Lines 872-877 Link Here
872
}
875
}
873
876
874
/*
877
/*
878
 * Sets the value of the given variable in the environment.  If the variable
879
 * already exists, its value is overriden.
880
 */
881
void
882
child_set_env(char ***envp, u_int *envsizep, const char *name,
883
	const char *value)
884
{
885
  child_set_env_safe(envp,envsizep,name,value,1);
886
}
887
888
/*
875
 * Reads environment variables from the given file and adds/overrides them
889
 * Reads environment variables from the given file and adds/overrides them
876
 * into the environment.  If the file does not exist, this does nothing.
890
 * into the environment.  If the file does not exist, this does nothing.
877
 * Otherwise, it must consist of empty lines, comments (line starts with '#')
891
 * Otherwise, it must consist of empty lines, comments (line starts with '#')
Lines 989-995 Link Here
989
		*var_val++ = '\0';
1003
		*var_val++ = '\0';
990
1004
991
		debug3("Copy environment: %s=%s", var_name, var_val);
1005
		debug3("Copy environment: %s=%s", var_name, var_val);
992
		child_set_env(env, envsize, var_name, var_val);
1006
		child_set_env_safe(env, envsize, var_name, var_val,0);
993
1007
994
		xfree(var_name);
1008
		xfree(var_name);
995
	}
1009
	}

Return to bug 1346