Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/crypto/dist/ssh More buffer size adjusted before allocation ...



details:   https://anonhg.NetBSD.org/src/rev/3c6fba957089
branches:  trunk
changeset: 552072:3c6fba957089
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Sep 17 23:19:02 2003 +0000

description:
More buffer size adjusted before allocation succeeded fixes. Bump to 20030917.
>From FreeBSD (with an additional one from me).

diffstat:

 crypto/dist/ssh/deattack.c  |   8 ++++----
 crypto/dist/ssh/misc.c      |  16 +++++++++-------
 crypto/dist/ssh/session.c   |  17 ++++++++++-------
 crypto/dist/ssh/ssh-agent.c |  17 +++++++++--------
 crypto/dist/ssh/version.h   |   4 ++--
 5 files changed, 34 insertions(+), 28 deletions(-)

diffs (198 lines):

diff -r 94636a24bb2d -r 3c6fba957089 crypto/dist/ssh/deattack.c
--- a/crypto/dist/ssh/deattack.c        Wed Sep 17 23:17:39 2003 +0000
+++ b/crypto/dist/ssh/deattack.c        Wed Sep 17 23:19:02 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: deattack.c,v 1.12 2003/07/10 01:09:44 lukem Exp $      */
+/*     $NetBSD: deattack.c,v 1.13 2003/09/17 23:19:02 christos Exp $   */
 /*
  * Cryptographic attack detector for ssh - source code
  *
@@ -20,7 +20,7 @@
 
 #include "includes.h"
 RCSID("$OpenBSD: deattack.c,v 1.18 2002/03/04 17:27:39 stevesk Exp $");
-__RCSID("$NetBSD: deattack.c,v 1.12 2003/07/10 01:09:44 lukem Exp $");
+__RCSID("$NetBSD: deattack.c,v 1.13 2003/09/17 23:19:02 christos Exp $");
 
 #include "deattack.h"
 #include "log.h"
@@ -102,12 +102,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 94636a24bb2d -r 3c6fba957089 crypto/dist/ssh/misc.c
--- a/crypto/dist/ssh/misc.c    Wed Sep 17 23:17:39 2003 +0000
+++ b/crypto/dist/ssh/misc.c    Wed Sep 17 23:19:02 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: misc.c,v 1.11 2003/07/10 01:09:45 lukem Exp $  */
+/*     $NetBSD: misc.c,v 1.12 2003/09/17 23:19:02 christos Exp $       */
 /*
  * Copyright (c) 2000 Markus Friedl.  All rights reserved.
  *
@@ -25,7 +25,7 @@
 
 #include "includes.h"
 RCSID("$OpenBSD: misc.c,v 1.20 2002/12/13 10:03:15 markus Exp $");
-__RCSID("$NetBSD: misc.c,v 1.11 2003/07/10 01:09:45 lukem Exp $");
+__RCSID("$NetBSD: misc.c,v 1.12 2003/09/17 23:19:02 christos Exp $");
 
 #include "misc.h"
 #include "log.h"
@@ -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 94636a24bb2d -r 3c6fba957089 crypto/dist/ssh/session.c
--- a/crypto/dist/ssh/session.c Wed Sep 17 23:17:39 2003 +0000
+++ b/crypto/dist/ssh/session.c Wed Sep 17 23:19:02 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: session.c,v 1.34 2003/07/24 15:31:54 itojun Exp $      */
+/*     $NetBSD: session.c,v 1.35 2003/09/17 23:19:02 christos Exp $    */
 /*
  * Copyright (c) 1995 Tatu Ylonen <ylo%cs.hut.fi@localhost>, Espoo, Finland
  *                    All rights reserved
@@ -35,7 +35,7 @@
 
 #include "includes.h"
 RCSID("$OpenBSD: session.c,v 1.154 2003/03/05 22:33:43 markus Exp $");
-__RCSID("$NetBSD: session.c,v 1.34 2003/07/24 15:31:54 itojun Exp $");
+__RCSID("$NetBSD: session.c,v 1.35 2003/09/17 23:19:02 christos Exp $");
 
 #include "ssh.h"
 #include "ssh1.h"
@@ -759,8 +759,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
@@ -777,12 +778,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 94636a24bb2d -r 3c6fba957089 crypto/dist/ssh/ssh-agent.c
--- a/crypto/dist/ssh/ssh-agent.c       Wed Sep 17 23:17:39 2003 +0000
+++ b/crypto/dist/ssh/ssh-agent.c       Wed Sep 17 23:19:02 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ssh-agent.c,v 1.21 2003/07/10 01:09:47 lukem Exp $     */
+/*     $NetBSD: ssh-agent.c,v 1.22 2003/09/17 23:19:03 christos Exp $  */
 /*
  * Author: Tatu Ylonen <ylo%cs.hut.fi@localhost>
  * Copyright (c) 1995 Tatu Ylonen <ylo%cs.hut.fi@localhost>, Espoo, Finland
@@ -37,7 +37,7 @@
 #include "includes.h"
 #include <sys/queue.h>
 RCSID("$OpenBSD: ssh-agent.c,v 1.108 2003/03/13 11:44:50 markus Exp $");
-__RCSID("$NetBSD: ssh-agent.c,v 1.21 2003/07/10 01:09:47 lukem Exp $");
+__RCSID("$NetBSD: ssh-agent.c,v 1.22 2003/09/17 23:19:03 christos Exp $");
 
 #include <openssl/evp.h>
 #include <openssl/md5.h>
@@ -766,7 +766,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));
@@ -777,25 +777,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
diff -r 94636a24bb2d -r 3c6fba957089 crypto/dist/ssh/version.h
--- a/crypto/dist/ssh/version.h Wed Sep 17 23:17:39 2003 +0000
+++ b/crypto/dist/ssh/version.h Wed Sep 17 23:19:02 2003 +0000
@@ -1,8 +1,8 @@
-/*     $NetBSD: version.h,v 1.31 2003/09/16 23:18:24 christos Exp $    */
+/*     $NetBSD: version.h,v 1.32 2003/09/17 23:19:04 christos Exp $    */
 /* $OpenBSD: version.h,v 1.37 2003/04/01 10:56:46 markus Exp $ */
 
 #define __OPENSSH_VERSION      "OpenSSH_3.6.1"
-#define __NETBSDSSH_VERSION    "NetBSD_Secure_Shell-20030916a"
+#define __NETBSDSSH_VERSION    "NetBSD_Secure_Shell-20030917"
 
 /*
  * it is important to retain OpenSSH version identification part, it is



Home | Main Index | Thread Index | Old Index