summaryrefslogtreecommitdiff
path: root/session.c
diff options
context:
space:
mode:
Diffstat (limited to 'session.c')
-rw-r--r--session.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/session.c b/session.c
index 2898ac518..4497f5c0b 100644
--- a/session.c
+++ b/session.c
@@ -33,7 +33,7 @@
33 */ 33 */
34 34
35#include "includes.h" 35#include "includes.h"
36RCSID("$OpenBSD: session.c,v 1.164 2003/09/18 08:49:45 markus Exp $"); 36RCSID("$OpenBSD: session.c,v 1.163 2003/08/31 13:29:05 markus Exp $");
37 37
38#include "ssh.h" 38#include "ssh.h"
39#include "ssh1.h" 39#include "ssh1.h"
@@ -798,9 +798,8 @@ void
798child_set_env(char ***envp, u_int *envsizep, const char *name, 798child_set_env(char ***envp, u_int *envsizep, const char *name,
799 const char *value) 799 const char *value)
800{ 800{
801 char **env;
802 u_int envsize;
803 u_int i, namelen; 801 u_int i, namelen;
802 char **env;
804 803
805 /* 804 /*
806 * If we're passed an uninitialized list, allocate a single null 805 * If we're passed an uninitialized list, allocate a single null
@@ -827,13 +826,12 @@ child_set_env(char ***envp, u_int *envsizep, const char *name,
827 xfree(env[i]); 826 xfree(env[i]);
828 } else { 827 } else {
829 /* New variable. Expand if necessary. */ 828 /* New variable. Expand if necessary. */
830 envsize = *envsizep; 829 if (i >= (*envsizep) - 1) {
831 if (i >= envsize - 1) { 830 if (*envsizep >= 1000)
832 if (envsize >= 1000) 831 fatal("child_set_env: too many env vars,"
833 fatal("child_set_env: too many env vars"); 832 " skipping: %.100s", name);
834 envsize += 50; 833 (*envsizep) += 50;
835 env = (*envp) = xrealloc(env, envsize * sizeof(char *)); 834 env = (*envp) = xrealloc(env, (*envsizep) * sizeof(char *));
836 *envsizep = envsize;
837 } 835 }
838 /* Need to set the NULL pointer at end of array beyond the new slot. */ 836 /* Need to set the NULL pointer at end of array beyond the new slot. */
839 env[i + 1] = NULL; 837 env[i + 1] = NULL;
@@ -914,7 +912,8 @@ static void
914read_etc_default_login(char ***env, u_int *envsize, uid_t uid) 912read_etc_default_login(char ***env, u_int *envsize, uid_t uid)
915{ 913{
916 char **tmpenv = NULL, *var; 914 char **tmpenv = NULL, *var;
917 u_int i, tmpenvsize = 0; 915 u_int i;
916 size_t tmpenvsize = 0;
918 mode_t mask; 917 mode_t mask;
919 918
920 /* 919 /*
@@ -924,9 +923,6 @@ read_etc_default_login(char ***env, u_int *envsize, uid_t uid)
924 */ 923 */
925 read_environment_file(&tmpenv, &tmpenvsize, "/etc/default/login"); 924 read_environment_file(&tmpenv, &tmpenvsize, "/etc/default/login");
926 925
927 if (tmpenv == NULL)
928 return;
929
930 if (uid == 0) 926 if (uid == 0)
931 var = child_get_env(tmpenv, "SUPATH"); 927 var = child_get_env(tmpenv, "SUPATH");
932 else 928 else