summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--bufaux.c18
-rw-r--r--buffer.h3
-rw-r--r--channels.c9
-rw-r--r--packet.c8
-rw-r--r--packet.h3
6 files changed, 36 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 4ac32e57f..e7fd87ba8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -58,6 +58,10 @@
58 - jmc@cvs.openbsd.org 2008/05/07 08:00:14 58 - jmc@cvs.openbsd.org 2008/05/07 08:00:14
59 [sshd_config.5] 59 [sshd_config.5]
60 sort; 60 sort;
61 - markus@cvs.openbsd.org 2008/05/08 06:59:01
62 [bufaux.c buffer.h channels.c packet.c packet.h]
63 avoid extra malloc/copy/free when receiving data over the net;
64 ~10% speedup for localhost-scp; ok djm@
61 65
6220080403 6620080403
63 - (djm) [openbsd-compat/bsd-poll.c] Include stdlib.h to avoid compile- 67 - (djm) [openbsd-compat/bsd-poll.c] Include stdlib.h to avoid compile-
@@ -3918,4 +3922,4 @@
3918 OpenServer 6 and add osr5bigcrypt support so when someone migrates 3922 OpenServer 6 and add osr5bigcrypt support so when someone migrates
3919 passwords between UnixWare and OpenServer they will still work. OK dtucker@ 3923 passwords between UnixWare and OpenServer they will still work. OK dtucker@
3920 3924
3921$Id: ChangeLog,v 1.4918 2008/05/19 04:59:02 djm Exp $ 3925$Id: ChangeLog,v 1.4919 2008/05/19 04:59:37 djm Exp $
diff --git a/bufaux.c b/bufaux.c
index cbdc22c64..f03363994 100644
--- a/bufaux.c
+++ b/bufaux.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bufaux.c,v 1.44 2006/08/03 03:34:41 deraadt Exp $ */ 1/* $OpenBSD: bufaux.c,v 1.45 2008/05/08 06:59:01 markus Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -197,6 +197,22 @@ buffer_get_string(Buffer *buffer, u_int *length_ptr)
197 return (ret); 197 return (ret);
198} 198}
199 199
200void *
201buffer_get_string_ptr(Buffer *buffer, u_int *length_ptr)
202{
203 void *ptr;
204 u_int len;
205
206 len = buffer_get_int(buffer);
207 if (len > 256 * 1024)
208 fatal("buffer_get_string_ptr: bad string length %u", len);
209 ptr = buffer_ptr(buffer);
210 buffer_consume(buffer, len);
211 if (length_ptr)
212 *length_ptr = len;
213 return (ptr);
214}
215
200/* 216/*
201 * Stores and arbitrary binary string in the buffer. 217 * Stores and arbitrary binary string in the buffer.
202 */ 218 */
diff --git a/buffer.h b/buffer.h
index ecc4aea83..d0f354ee7 100644
--- a/buffer.h
+++ b/buffer.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: buffer.h,v 1.16 2006/08/03 03:34:41 deraadt Exp $ */ 1/* $OpenBSD: buffer.h,v 1.17 2008/05/08 06:59:01 markus Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -66,6 +66,7 @@ int buffer_get_char(Buffer *);
66void buffer_put_char(Buffer *, int); 66void buffer_put_char(Buffer *, int);
67 67
68void *buffer_get_string(Buffer *, u_int *); 68void *buffer_get_string(Buffer *, u_int *);
69void *buffer_get_string_ptr(Buffer *, u_int *);
69void buffer_put_string(Buffer *, const void *, u_int); 70void buffer_put_string(Buffer *, const void *, u_int);
70void buffer_put_cstring(Buffer *, const char *); 71void buffer_put_cstring(Buffer *, const char *);
71 72
diff --git a/channels.c b/channels.c
index b6bd901f0..05c23e59c 100644
--- a/channels.c
+++ b/channels.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: channels.c,v 1.273 2008/04/02 21:36:51 markus Exp $ */ 1/* $OpenBSD: channels.c,v 1.274 2008/05/08 06:59:01 markus Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -2012,7 +2012,7 @@ channel_input_data(int type, u_int32_t seq, void *ctxt)
2012 return; 2012 return;
2013 2013
2014 /* Get the data. */ 2014 /* Get the data. */
2015 data = packet_get_string(&data_len); 2015 data = packet_get_string_ptr(&data_len);
2016 2016
2017 /* 2017 /*
2018 * Ignore data for protocol > 1.3 if output end is no longer open. 2018 * Ignore data for protocol > 1.3 if output end is no longer open.
@@ -2026,7 +2026,6 @@ channel_input_data(int type, u_int32_t seq, void *ctxt)
2026 c->local_window -= data_len; 2026 c->local_window -= data_len;
2027 c->local_consumed += data_len; 2027 c->local_consumed += data_len;
2028 } 2028 }
2029 xfree(data);
2030 return; 2029 return;
2031 } 2030 }
2032 2031
@@ -2038,17 +2037,15 @@ channel_input_data(int type, u_int32_t seq, void *ctxt)
2038 if (data_len > c->local_window) { 2037 if (data_len > c->local_window) {
2039 logit("channel %d: rcvd too much data %d, win %d", 2038 logit("channel %d: rcvd too much data %d, win %d",
2040 c->self, data_len, c->local_window); 2039 c->self, data_len, c->local_window);
2041 xfree(data);
2042 return; 2040 return;
2043 } 2041 }
2044 c->local_window -= data_len; 2042 c->local_window -= data_len;
2045 } 2043 }
2046 packet_check_eom();
2047 if (c->datagram) 2044 if (c->datagram)
2048 buffer_put_string(&c->output, data, data_len); 2045 buffer_put_string(&c->output, data, data_len);
2049 else 2046 else
2050 buffer_append(&c->output, data, data_len); 2047 buffer_append(&c->output, data, data_len);
2051 xfree(data); 2048 packet_check_eom();
2052} 2049}
2053 2050
2054/* ARGSUSED */ 2051/* ARGSUSED */
diff --git a/packet.c b/packet.c
index 6afe24b9f..a34c040d6 100644
--- a/packet.c
+++ b/packet.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: packet.c,v 1.151 2008/02/22 20:44:02 dtucker Exp $ */ 1/* $OpenBSD: packet.c,v 1.152 2008/05/08 06:59:01 markus Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1332,6 +1332,12 @@ packet_get_string(u_int *length_ptr)
1332 return buffer_get_string(&incoming_packet, length_ptr); 1332 return buffer_get_string(&incoming_packet, length_ptr);
1333} 1333}
1334 1334
1335void *
1336packet_get_string_ptr(u_int *length_ptr)
1337{
1338 return buffer_get_string_ptr(&incoming_packet, length_ptr);
1339}
1340
1335/* 1341/*
1336 * Sends a diagnostic message from the server to the client. This message 1342 * Sends a diagnostic message from the server to the client. This message
1337 * can be sent at any time (but not while constructing another message). The 1343 * can be sent at any time (but not while constructing another message). The
diff --git a/packet.h b/packet.h
index c1b9b3bd1..927e0831c 100644
--- a/packet.h
+++ b/packet.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: packet.h,v 1.46 2008/02/22 20:44:02 dtucker Exp $ */ 1/* $OpenBSD: packet.h,v 1.47 2008/05/08 06:59:01 markus Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -58,6 +58,7 @@ void packet_get_bignum(BIGNUM * value);
58void packet_get_bignum2(BIGNUM * value); 58void packet_get_bignum2(BIGNUM * value);
59void *packet_get_raw(u_int *length_ptr); 59void *packet_get_raw(u_int *length_ptr);
60void *packet_get_string(u_int *length_ptr); 60void *packet_get_string(u_int *length_ptr);
61void *packet_get_string_ptr(u_int *length_ptr);
61void packet_disconnect(const char *fmt,...) __attribute__((format(printf, 1, 2))); 62void packet_disconnect(const char *fmt,...) __attribute__((format(printf, 1, 2)));
62void packet_send_debug(const char *fmt,...) __attribute__((format(printf, 1, 2))); 63void packet_send_debug(const char *fmt,...) __attribute__((format(printf, 1, 2)));
63 64