summaryrefslogtreecommitdiff
path: root/session.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2003-09-22 21:04:23 +1000
committerDarren Tucker <dtucker@zip.com.au>2003-09-22 21:04:23 +1000
commitfb16b2411eda857cd358dc4c9c63b66edc217a51 (patch)
treeb1959332991a29ddf752a6e4e9e29a80d139d41c /session.c
parentd1d41b318117258bd25f2eb2789ba3b91408bd16 (diff)
downloadopenssh-git-fb16b2411eda857cd358dc4c9c63b66edc217a51.tar.gz
- markus@cvs.openbsd.org 2003/09/18 08:49:45
[deattack.c misc.c session.c ssh-agent.c] more buffer allocation fixes; from Solar Designer; CAN-2003-0682; ok millert@
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 616fee97..2898ac51 100644
--- a/session.c
+++ b/session.c
@@ -33,7 +33,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: session.c,v 1.163 2003/08/31 13:29:05 markus Exp $");
+RCSID("$OpenBSD: session.c,v 1.164 2003/09/18 08:49:45 markus Exp $");
#include "ssh.h"
#include "ssh1.h"
@@ -798,8 +798,9 @@ void
child_set_env(char ***envp, u_int *envsizep, const char *name,
const char *value)
{
- u_int i, namelen;
char **env;
+ u_int envsize;
+ u_int i, namelen;
/*
* 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,
xfree(env[i]);
} else {
/* New variable. Expand if necessary. */
- if (i >= (*envsizep) - 1) {
- if (*envsizep >= 1000)
- fatal("child_set_env: too many env vars,"
- " skipping: %.100s", name);
- (*envsizep) += 50;
- env = (*envp) = xrealloc(env, (*envsizep) * sizeof(char *));
+ envsize = *envsizep;
+ if (i >= envsize - 1) {
+ if (envsize >= 1000)
+ fatal("child_set_env: too many env vars");
+ envsize += 50;
+ env = (*envp) = xrealloc(env, envsize * sizeof(char *));
+ *envsizep = envsize;
}
/* Need to set the NULL pointer at end of array beyond the new slot. */
env[i + 1] = NULL;