diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2003-09-18 08:49:46 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2003-09-18 08:49:46 +0000 |
commit | 542416f990be470d79311bc4cf1bc8477edd9396 (patch) | |
tree | 43af1afb8ba6f585fd1e0ee137afb666822d28cc /usr.bin/ssh/session.c | |
parent | 5812a5bf57ae0811c582a45039f9ff7cacb8cec2 (diff) |
more buffer allocation fixes; from Solar Designer; CAN-2003-0682; ok millert@
Diffstat (limited to 'usr.bin/ssh/session.c')
-rw-r--r-- | usr.bin/ssh/session.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/usr.bin/ssh/session.c b/usr.bin/ssh/session.c index b5be7d1aef0..0b4592a1378 100644 --- a/usr.bin/ssh/session.c +++ b/usr.bin/ssh/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" @@ -695,8 +695,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; /* * Find the slot where the value should be stored. If the variable @@ -713,12 +714,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; |