Source-Changes-HG archive

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

[src/trunk]: src/crypto/dist/ssh Do not record expanded size before attemptin...



details:   https://anonhg.NetBSD.org/src/rev/4181fa0124c9
branches:  trunk
changeset: 552027:4181fa0124c9
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Sep 16 13:22:57 2003 +0000

description:
Do not record expanded size before attempting to reallocate the associated
memory. From OpenBSD, via FreeBSD.

diffstat:

 crypto/dist/ssh/buffer.c |  14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diffs (43 lines):

diff -r f2005c29fc27 -r 4181fa0124c9 crypto/dist/ssh/buffer.c
--- a/crypto/dist/ssh/buffer.c  Tue Sep 16 12:08:23 2003 +0000
+++ b/crypto/dist/ssh/buffer.c  Tue Sep 16 13:22:57 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: buffer.c,v 1.2 2003/07/10 01:09:43 lukem Exp $ */
+/*     $NetBSD: buffer.c,v 1.3 2003/09/16 13:22:57 christos Exp $      */
 /*
  * Author: Tatu Ylonen <ylo%cs.hut.fi@localhost>
  * Copyright (c) 1995 Tatu Ylonen <ylo%cs.hut.fi@localhost>, Espoo, Finland
@@ -14,7 +14,7 @@
 
 #include "includes.h"
 RCSID("$OpenBSD: buffer.c,v 1.16 2002/06/26 08:54:18 markus Exp $");
-__RCSID("$NetBSD: buffer.c,v 1.2 2003/07/10 01:09:43 lukem Exp $");
+__RCSID("$NetBSD: buffer.c,v 1.3 2003/09/16 13:22:57 christos Exp $");
 
 #include "xmalloc.h"
 #include "buffer.h"
@@ -71,6 +71,7 @@
 void *
 buffer_append_space(Buffer *buffer, u_int len)
 {
+       u_int newlen;
        void *p;
 
        if (len > 0x100000)
@@ -100,11 +101,12 @@
                goto restart;
        }
        /* Increase the size of the buffer and retry. */
-       buffer->alloc += len + 32768;
-       if (buffer->alloc > 0xa00000)
+       newlen = buffer->alloc + len + 32768;
+       if (newlen > 0xa00000)
                fatal("buffer_append_space: alloc %u not supported",
-                   buffer->alloc);
-       buffer->buf = xrealloc(buffer->buf, buffer->alloc);
+                   newlen);
+       buffer->buf = xrealloc(buffer->buf, newlen);
+       buffer->alloc = newlen;
        goto restart;
        /* NOTREACHED */
 }



Home | Main Index | Thread Index | Old Index