Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-6]: src/crypto/dist/ssh bring more buffer length adjusting afte...
details: https://anonhg.NetBSD.org/src/rev/cb41a38f7dd6
branches: netbsd-1-6
changeset: 530720:cb41a38f7dd6
user: christos <christos%NetBSD.org@localhost>
date: Wed Sep 17 23:25:51 2003 +0000
description:
bring more buffer length adjusting after allocation fixes from head.
diffstat:
crypto/dist/ssh/deattack.c | 6 +++---
crypto/dist/ssh/misc.c | 16 +++++++++-------
crypto/dist/ssh/session.c | 15 +++++++++------
crypto/dist/ssh/ssh-agent.c | 15 ++++++++-------
4 files changed, 29 insertions(+), 23 deletions(-)
diffs (150 lines):
diff -r ac0b3c47b949 -r cb41a38f7dd6 crypto/dist/ssh/deattack.c
--- a/crypto/dist/ssh/deattack.c Wed Sep 17 00:11:35 2003 +0000
+++ b/crypto/dist/ssh/deattack.c Wed Sep 17 23:25:51 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: deattack.c,v 1.11 2002/03/08 02:00:52 itojun Exp $ */
+/* $NetBSD: deattack.c,v 1.11.2.1 2003/09/17 23:25:51 christos Exp $ */
/*
* Cryptographic attack detector for ssh - source code
*
@@ -101,12 +101,12 @@
if (h == NULL) {
debug("Installing crc compensation attack detector.");
+ h = (u_int16_t *) xmalloc(l * HASH_ENTRYSIZE);
n = l;
- h = (u_int16_t *) xmalloc(n * HASH_ENTRYSIZE);
} else {
if (l > n) {
+ h = (u_int16_t *) xrealloc(h, l * HASH_ENTRYSIZE);
n = l;
- h = (u_int16_t *) xrealloc(h, n * HASH_ENTRYSIZE);
}
}
diff -r ac0b3c47b949 -r cb41a38f7dd6 crypto/dist/ssh/misc.c
--- a/crypto/dist/ssh/misc.c Wed Sep 17 00:11:35 2003 +0000
+++ b/crypto/dist/ssh/misc.c Wed Sep 17 23:25:51 2003 +0000
@@ -1,5 +1,5 @@
-/* $NetBSD: misc.c,v 1.9 2002/03/08 02:00:53 itojun Exp $ */
-/* $NetBSD: misc.c,v 1.9 2002/03/08 02:00:53 itojun Exp $ */
+/* $NetBSD: misc.c,v 1.9.2.1 2003/09/17 23:25:51 christos Exp $ */
+/* $NetBSD: misc.c,v 1.9.2.1 2003/09/17 23:25:51 christos Exp $ */
/*
* Copyright (c) 2000 Markus Friedl. All rights reserved.
*
@@ -304,18 +304,20 @@
{
va_list ap;
char buf[1024];
+ int nalloc;
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
if (args->list == NULL) {
- args->nalloc = 32;
+ nalloc = 32;
args->num = 0;
} else if (args->num+2 >= args->nalloc)
- args->nalloc *= 2;
+ nalloc *= 2;
- args->list = xrealloc(args->list, args->nalloc * sizeof(char *));
- args->list[args->num++] = xstrdup(buf);
- args->list[args->num] = NULL;
+ args->list = xrealloc(args->list, nalloc * sizeof(char *));
+ args->nalloc = nalloc;
+ args->list[args->num] = xstrdup(buf);
+ args->list[++(args->num)] = NULL;
}
diff -r ac0b3c47b949 -r cb41a38f7dd6 crypto/dist/ssh/session.c
--- a/crypto/dist/ssh/session.c Wed Sep 17 00:11:35 2003 +0000
+++ b/crypto/dist/ssh/session.c Wed Sep 17 23:25:51 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: session.c,v 1.23.2.1 2002/06/26 16:53:50 tv Exp $ */
+/* $NetBSD: session.c,v 1.23.2.2 2003/09/17 23:25:52 christos Exp $ */
/*
* Copyright (c) 1995 Tatu Ylonen <ylo%cs.hut.fi@localhost>, Espoo, Finland
* All rights reserved
@@ -748,8 +748,9 @@
child_set_env(char ***envp, u_int *envsizep, const char *name,
const char *value)
{
+ char **env;
+ u_int envsize;
u_int i, namelen;
- char **env;
/*
* Find the slot where the value should be stored. If the variable
@@ -766,12 +767,14 @@
xfree(env[i]);
} else {
/* New variable. Expand if necessary. */
- if (i >= (*envsizep) - 1) {
- if (*envsizep >= 1000)
+ envsize = *envsizep;
+ if (i >= envsize - 1) {
+ if (envsize >= 1000)
fatal("child_set_env: too many env vars,"
" skipping: %.100s", name);
- (*envsizep) += 50;
- env = (*envp) = xrealloc(env, (*envsizep) * sizeof(char *));
+ 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;
diff -r ac0b3c47b949 -r cb41a38f7dd6 crypto/dist/ssh/ssh-agent.c
--- a/crypto/dist/ssh/ssh-agent.c Wed Sep 17 00:11:35 2003 +0000
+++ b/crypto/dist/ssh/ssh-agent.c Wed Sep 17 23:25:51 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ssh-agent.c,v 1.15.2.1 2002/06/26 16:54:06 tv Exp $ */
+/* $NetBSD: ssh-agent.c,v 1.15.2.2 2003/09/17 23:25:53 christos Exp $ */
/*
* Author: Tatu Ylonen <ylo%cs.hut.fi@localhost>
* Copyright (c) 1995 Tatu Ylonen <ylo%cs.hut.fi@localhost>, Espoo, Finland
@@ -711,7 +711,7 @@
static void
new_socket(sock_type type, int fd)
{
- u_int i, old_alloc;
+ u_int i, old_alloc, new_alloc;
if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0)
error("fcntl O_NONBLOCK: %s", strerror(errno));
@@ -722,25 +722,26 @@
for (i = 0; i < sockets_alloc; i++)
if (sockets[i].type == AUTH_UNUSED) {
sockets[i].fd = fd;
- sockets[i].type = type;
buffer_init(&sockets[i].input);
buffer_init(&sockets[i].output);
buffer_init(&sockets[i].request);
+ sockets[i].type = type;
return;
}
old_alloc = sockets_alloc;
- sockets_alloc += 10;
+ new_alloc = sockets_alloc + 10;
if (sockets)
- sockets = xrealloc(sockets, sockets_alloc * sizeof(sockets[0]));
+ sockets = xrealloc(sockets, new_alloc * sizeof(sockets[0]));
else
- sockets = xmalloc(sockets_alloc * sizeof(sockets[0]));
+ sockets = xmalloc(new_alloc * sizeof(sockets[0]));
for (i = old_alloc; i < sockets_alloc; i++)
sockets[i].type = AUTH_UNUSED;
- sockets[old_alloc].type = type;
+ sockets_alloc = new_alloc;
sockets[old_alloc].fd = fd;
buffer_init(&sockets[old_alloc].input);
buffer_init(&sockets[old_alloc].output);
buffer_init(&sockets[old_alloc].request);
+ sockets[old_alloc].type = type;
}
static int
Home |
Main Index |
Thread Index |
Old Index