diff options
author | Damien Miller <djm@mindrot.org> | 2006-03-26 14:22:47 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2006-03-26 14:22:47 +1100 |
commit | 36812092ecb11a25ca9d6d87fdeaf53e371c5043 (patch) | |
tree | 257ccc18998146f7f6e6c25cbb0ff9bd6de946a5 /session.c | |
parent | 07d86bec5eeaf19fe33dca99c8ebcbe9a77c3938 (diff) |
- djm@cvs.openbsd.org 2006/03/25 01:13:23
[buffer.c channels.c deattack.c misc.c scp.c session.c sftp-client.c]
[sftp-server.c ssh-agent.c ssh-rsa.c xmalloc.c xmalloc.h auth-pam.c]
[uidswap.c]
change OpenSSH's xrealloc() function from being xrealloc(p, new_size)
to xrealloc(p, new_nmemb, new_itemsize).
realloc is particularly prone to integer overflows because it is
almost always allocating "n * size" bytes, so this is a far safer
API; ok deraadt@
Diffstat (limited to 'session.c')
-rw-r--r-- | session.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -837,7 +837,7 @@ child_set_env(char ***envp, u_int *envsizep, const char *name, | |||
837 | if (envsize >= 1000) | 837 | if (envsize >= 1000) |
838 | fatal("child_set_env: too many env vars"); | 838 | fatal("child_set_env: too many env vars"); |
839 | envsize += 50; | 839 | envsize += 50; |
840 | env = (*envp) = xrealloc(env, envsize * sizeof(char *)); | 840 | env = (*envp) = xrealloc(env, envsize, sizeof(char *)); |
841 | *envsizep = envsize; | 841 | *envsizep = envsize; |
842 | } | 842 | } |
843 | /* Need to set the NULL pointer at end of array beyond the new slot. */ | 843 | /* Need to set the NULL pointer at end of array beyond the new slot. */ |
@@ -1941,8 +1941,8 @@ session_env_req(Session *s) | |||
1941 | for (i = 0; i < options.num_accept_env; i++) { | 1941 | for (i = 0; i < options.num_accept_env; i++) { |
1942 | if (match_pattern(name, options.accept_env[i])) { | 1942 | if (match_pattern(name, options.accept_env[i])) { |
1943 | debug2("Setting env %d: %s=%s", s->num_env, name, val); | 1943 | debug2("Setting env %d: %s=%s", s->num_env, name, val); |
1944 | s->env = xrealloc(s->env, sizeof(*s->env) * | 1944 | s->env = xrealloc(s->env, s->num_env + 1, |
1945 | (s->num_env + 1)); | 1945 | sizeof(*s->env)); |
1946 | s->env[s->num_env].name = name; | 1946 | s->env[s->num_env].name = name; |
1947 | s->env[s->num_env].val = val; | 1947 | s->env[s->num_env].val = val; |
1948 | s->num_env++; | 1948 | s->num_env++; |