diff options
author | Darren Tucker <dtucker@zip.com.au> | 2003-09-23 18:59:08 +1000 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2003-09-23 18:59:08 +1000 |
commit | a05ec477b32c50aa793d865a231a3ec9d0ab1234 (patch) | |
tree | ed5a8892226f8dd4da673ece5422ecd15ba207a2 | |
parent | e1318fb07f775f2d54cacd98c217de9c25fbe964 (diff) |
- 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@
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | deattack.c | 6 | ||||
-rw-r--r-- | misc.c | 13 | ||||
-rw-r--r-- | session.c | 18 | ||||
-rw-r--r-- | ssh-agent.c | 17 |
5 files changed, 35 insertions, 25 deletions
@@ -6,6 +6,10 @@ | |||
6 | - markus@cvs.openbsd.org 2003/09/18 07:54:48 | 6 | - markus@cvs.openbsd.org 2003/09/18 07:54:48 |
7 | [buffer.c] | 7 | [buffer.c] |
8 | protect against double free; #660; zardoz at users.sf.net | 8 | protect against double free; #660; zardoz at users.sf.net |
9 | - markus@cvs.openbsd.org 2003/09/18 08:49:45 | ||
10 | [deattack.c misc.c session.c ssh-agent.c] | ||
11 | more buffer allocation fixes; from Solar Designer; CAN-2003-0682; | ||
12 | ok millert@ | ||
9 | 13 | ||
10 | 20030922 | 14 | 20030922 |
11 | - (dtucker) [Makefile.in] Bug #644: Fix "make clean" for out-of-tree | 15 | - (dtucker) [Makefile.in] Bug #644: Fix "make clean" for out-of-tree |
@@ -1171,4 +1175,4 @@ | |||
1171 | - Fix sshd BindAddress and -b options for systems using fake-getaddrinfo. | 1175 | - Fix sshd BindAddress and -b options for systems using fake-getaddrinfo. |
1172 | Report from murple@murple.net, diagnosis from dtucker@zip.com.au | 1176 | Report from murple@murple.net, diagnosis from dtucker@zip.com.au |
1173 | 1177 | ||
1174 | $Id: ChangeLog,v 1.2994.2.29 2003/09/23 08:55:43 dtucker Exp $ | 1178 | $Id: ChangeLog,v 1.2994.2.30 2003/09/23 08:59:08 dtucker Exp $ |
diff --git a/deattack.c b/deattack.c index 0442501e7..8b55d6686 100644 --- a/deattack.c +++ b/deattack.c | |||
@@ -18,7 +18,7 @@ | |||
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include "includes.h" | 20 | #include "includes.h" |
21 | RCSID("$OpenBSD: deattack.c,v 1.18 2002/03/04 17:27:39 stevesk Exp $"); | 21 | RCSID("$OpenBSD: deattack.c,v 1.19 2003/09/18 08:49:45 markus Exp $"); |
22 | 22 | ||
23 | #include "deattack.h" | 23 | #include "deattack.h" |
24 | #include "log.h" | 24 | #include "log.h" |
@@ -100,12 +100,12 @@ detect_attack(u_char *buf, u_int32_t len, u_char *IV) | |||
100 | 100 | ||
101 | if (h == NULL) { | 101 | if (h == NULL) { |
102 | debug("Installing crc compensation attack detector."); | 102 | debug("Installing crc compensation attack detector."); |
103 | h = (u_int16_t *) xmalloc(l * HASH_ENTRYSIZE); | ||
103 | n = l; | 104 | n = l; |
104 | h = (u_int16_t *) xmalloc(n * HASH_ENTRYSIZE); | ||
105 | } else { | 105 | } else { |
106 | if (l > n) { | 106 | if (l > n) { |
107 | h = (u_int16_t *) xrealloc(h, l * HASH_ENTRYSIZE); | ||
107 | n = l; | 108 | n = l; |
108 | h = (u_int16_t *) xrealloc(h, n * HASH_ENTRYSIZE); | ||
109 | } | 109 | } |
110 | } | 110 | } |
111 | 111 | ||
@@ -23,7 +23,7 @@ | |||
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include "includes.h" | 25 | #include "includes.h" |
26 | RCSID("$OpenBSD: misc.c,v 1.21 2003/04/12 10:15:36 markus Exp $"); | 26 | RCSID("$OpenBSD: misc.c,v 1.22 2003/09/18 08:49:45 markus Exp $"); |
27 | 27 | ||
28 | #include "misc.h" | 28 | #include "misc.h" |
29 | #include "log.h" | 29 | #include "log.h" |
@@ -308,18 +308,21 @@ addargs(arglist *args, char *fmt, ...) | |||
308 | { | 308 | { |
309 | va_list ap; | 309 | va_list ap; |
310 | char buf[1024]; | 310 | char buf[1024]; |
311 | int nalloc; | ||
311 | 312 | ||
312 | va_start(ap, fmt); | 313 | va_start(ap, fmt); |
313 | vsnprintf(buf, sizeof(buf), fmt, ap); | 314 | vsnprintf(buf, sizeof(buf), fmt, ap); |
314 | va_end(ap); | 315 | va_end(ap); |
315 | 316 | ||
317 | nalloc = args->nalloc; | ||
316 | if (args->list == NULL) { | 318 | if (args->list == NULL) { |
317 | args->nalloc = 32; | 319 | nalloc = 32; |
318 | args->num = 0; | 320 | args->num = 0; |
319 | } else if (args->num+2 >= args->nalloc) | 321 | } else if (args->num+2 >= nalloc) |
320 | args->nalloc *= 2; | 322 | nalloc *= 2; |
321 | 323 | ||
322 | args->list = xrealloc(args->list, args->nalloc * sizeof(char *)); | 324 | args->list = xrealloc(args->list, nalloc * sizeof(char *)); |
325 | args->nalloc = nalloc; | ||
323 | args->list[args->num++] = xstrdup(buf); | 326 | args->list[args->num++] = xstrdup(buf); |
324 | args->list[args->num] = NULL; | 327 | args->list[args->num] = NULL; |
325 | } | 328 | } |
@@ -33,7 +33,7 @@ | |||
33 | */ | 33 | */ |
34 | 34 | ||
35 | #include "includes.h" | 35 | #include "includes.h" |
36 | RCSID("$OpenBSD: session.c,v 1.163 2003/08/31 13:29:05 markus Exp $"); | 36 | RCSID("$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 | |||
798 | child_set_env(char ***envp, u_int *envsizep, const char *name, | 798 | child_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; |
diff --git a/ssh-agent.c b/ssh-agent.c index c05c61468..e1e6cae9b 100644 --- a/ssh-agent.c +++ b/ssh-agent.c | |||
@@ -35,7 +35,7 @@ | |||
35 | 35 | ||
36 | #include "includes.h" | 36 | #include "includes.h" |
37 | #include "openbsd-compat/sys-queue.h" | 37 | #include "openbsd-compat/sys-queue.h" |
38 | RCSID("$OpenBSD: ssh-agent.c,v 1.111 2003/06/12 19:12:03 markus Exp $"); | 38 | RCSID("$OpenBSD: ssh-agent.c,v 1.112 2003/09/18 08:49:45 markus Exp $"); |
39 | 39 | ||
40 | #include <openssl/evp.h> | 40 | #include <openssl/evp.h> |
41 | #include <openssl/md5.h> | 41 | #include <openssl/md5.h> |
@@ -784,7 +784,7 @@ process_message(SocketEntry *e) | |||
784 | static void | 784 | static void |
785 | new_socket(sock_type type, int fd) | 785 | new_socket(sock_type type, int fd) |
786 | { | 786 | { |
787 | u_int i, old_alloc; | 787 | u_int i, old_alloc, new_alloc; |
788 | 788 | ||
789 | if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) | 789 | if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) |
790 | error("fcntl O_NONBLOCK: %s", strerror(errno)); | 790 | error("fcntl O_NONBLOCK: %s", strerror(errno)); |
@@ -795,25 +795,26 @@ new_socket(sock_type type, int fd) | |||
795 | for (i = 0; i < sockets_alloc; i++) | 795 | for (i = 0; i < sockets_alloc; i++) |
796 | if (sockets[i].type == AUTH_UNUSED) { | 796 | if (sockets[i].type == AUTH_UNUSED) { |
797 | sockets[i].fd = fd; | 797 | sockets[i].fd = fd; |
798 | sockets[i].type = type; | ||
799 | buffer_init(&sockets[i].input); | 798 | buffer_init(&sockets[i].input); |
800 | buffer_init(&sockets[i].output); | 799 | buffer_init(&sockets[i].output); |
801 | buffer_init(&sockets[i].request); | 800 | buffer_init(&sockets[i].request); |
801 | sockets[i].type = type; | ||
802 | return; | 802 | return; |
803 | } | 803 | } |
804 | old_alloc = sockets_alloc; | 804 | old_alloc = sockets_alloc; |
805 | sockets_alloc += 10; | 805 | new_alloc = sockets_alloc + 10; |
806 | if (sockets) | 806 | if (sockets) |
807 | sockets = xrealloc(sockets, sockets_alloc * sizeof(sockets[0])); | 807 | sockets = xrealloc(sockets, new_alloc * sizeof(sockets[0])); |
808 | else | 808 | else |
809 | sockets = xmalloc(sockets_alloc * sizeof(sockets[0])); | 809 | sockets = xmalloc(new_alloc * sizeof(sockets[0])); |
810 | for (i = old_alloc; i < sockets_alloc; i++) | 810 | for (i = old_alloc; i < new_alloc; i++) |
811 | sockets[i].type = AUTH_UNUSED; | 811 | sockets[i].type = AUTH_UNUSED; |
812 | sockets[old_alloc].type = type; | 812 | sockets_alloc = new_alloc; |
813 | sockets[old_alloc].fd = fd; | 813 | sockets[old_alloc].fd = fd; |
814 | buffer_init(&sockets[old_alloc].input); | 814 | buffer_init(&sockets[old_alloc].input); |
815 | buffer_init(&sockets[old_alloc].output); | 815 | buffer_init(&sockets[old_alloc].output); |
816 | buffer_init(&sockets[old_alloc].request); | 816 | buffer_init(&sockets[old_alloc].request); |
817 | sockets[old_alloc].type = type; | ||
817 | } | 818 | } |
818 | 819 | ||
819 | static int | 820 | static int |