summaryrefslogtreecommitdiff
path: root/session.c
diff options
context:
space:
mode:
Diffstat (limited to 'session.c')
-rw-r--r--session.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/session.c b/session.c
index 616fee971..2898ac518 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.163 2003/08/31 13:29:05 markus Exp $"); 36RCSID("$OpenBSD: session.c,v 1.164 2003/09/18 08:49:45 markus Exp $");
37 37
38#include "ssh.h" 38#include "ssh.h"
39#include "ssh1.h" 39#include "ssh1.h"
@@ -798,8 +798,9 @@ 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 u_int i, namelen;
802 char **env; 801 char **env;
802 u_int envsize;
803 u_int i, namelen;
803 804
804 /* 805 /*
805 * If we're passed an uninitialized list, allocate a single null 806 * If we're passed an uninitialized list, allocate a single null
@@ -826,12 +827,13 @@ child_set_env(char ***envp, u_int *envsizep, const char *name,
826 xfree(env[i]); 827 xfree(env[i]);
827 } else { 828 } else {
828 /* New variable. Expand if necessary. */ 829 /* New variable. Expand if necessary. */
829 if (i >= (*envsizep) - 1) { 830 envsize = *envsizep;
830 if (*envsizep >= 1000) 831 if (i >= envsize - 1) {
831 fatal("child_set_env: too many env vars," 832 if (envsize >= 1000)
832 " skipping: %.100s", name); 833 fatal("child_set_env: too many env vars");
833 (*envsizep) += 50; 834 envsize += 50;
834 env = (*envp) = xrealloc(env, (*envsizep) * sizeof(char *)); 835 env = (*envp) = xrealloc(env, envsize * sizeof(char *));
836 *envsizep = envsize;
835 } 837 }
836 /* Need to set the NULL pointer at end of array beyond the new slot. */ 838 /* Need to set the NULL pointer at end of array beyond the new slot. */
837 env[i + 1] = NULL; 839 env[i + 1] = NULL;