diff options
author | Colin Watson <cjwatson@debian.org> | 2007-06-12 16:16:35 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2007-06-12 16:16:35 +0000 |
commit | b7e40fa9da0b5491534a429dadb321eab5a77558 (patch) | |
tree | bed1da11e9f829925797aa093e379fc0b5868ecd /buffer.c | |
parent | 4f84beedf1005e44ff33c854abd6b711ffc0adb7 (diff) | |
parent | 086ea76990b1e6287c24b6db74adffd4605eb3b0 (diff) |
* New upstream release (closes: #395507, #397961, #420035). Important
changes not previously backported to 4.3p2:
- 4.4/4.4p1 (http://www.openssh.org/txt/release-4.4):
+ On portable OpenSSH, fix a GSSAPI authentication abort that could be
used to determine the validity of usernames on some platforms.
+ Implemented conditional configuration in sshd_config(5) using the
"Match" directive. This allows some configuration options to be
selectively overridden if specific criteria (based on user, group,
hostname and/or address) are met. So far a useful subset of
post-authentication options are supported and more are expected to
be added in future releases.
+ Add support for Diffie-Hellman group exchange key agreement with a
final hash of SHA256.
+ Added a "ForceCommand" directive to sshd_config(5). Similar to the
command="..." option accepted in ~/.ssh/authorized_keys, this forces
the execution of the specified command regardless of what the user
requested. This is very useful in conjunction with the new "Match"
option.
+ Add a "PermitOpen" directive to sshd_config(5). This mirrors the
permitopen="..." authorized_keys option, allowing fine-grained
control over the port-forwardings that a user is allowed to
establish.
+ Add optional logging of transactions to sftp-server(8).
+ ssh(1) will now record port numbers for hosts stored in
~/.ssh/known_hosts when a non-standard port has been requested
(closes: #50612).
+ Add an "ExitOnForwardFailure" option to cause ssh(1) to exit (with a
non-zero exit code) when requested port forwardings could not be
established.
+ Extend sshd_config(5) "SubSystem" declarations to allow the
specification of command-line arguments.
+ Replacement of all integer overflow susceptible invocations of
malloc(3) and realloc(3) with overflow-checking equivalents.
+ Many manpage fixes and improvements.
+ Add optional support for OpenSSL hardware accelerators (engines),
enabled using the --with-ssl-engine configure option.
+ Tokens in configuration files may be double-quoted in order to
contain spaces (closes: #319639).
+ Move a debug() call out of a SIGCHLD handler, fixing a hang when the
session exits very quickly (closes: #307890).
+ Fix some incorrect buffer allocation calculations (closes: #410599).
+ ssh-add doesn't ask for a passphrase if key file permissions are too
liberal (closes: #103677).
+ Likewise, ssh doesn't ask either (closes: #99675).
- 4.6/4.6p1 (http://www.openssh.org/txt/release-4.6):
+ sshd now allows the enabling and disabling of authentication methods
on a per user, group, host and network basis via the Match directive
in sshd_config.
+ Fixed an inconsistent check for a terminal when displaying scp
progress meter (closes: #257524).
+ Fix "hang on exit" when background processes are running at the time
of exit on a ttyful/login session (closes: #88337).
* Update to current GSSAPI patch from
http://www.sxw.org.uk/computing/patches/openssh-4.6p1-gsskex-20070312.patch;
install ChangeLog.gssapi.
Diffstat (limited to 'buffer.c')
-rw-r--r-- | buffer.c | 69 |
1 files changed, 55 insertions, 14 deletions
@@ -1,3 +1,4 @@ | |||
1 | /* $OpenBSD: buffer.c,v 1.31 2006/08/03 03:34:41 deraadt Exp $ */ | ||
1 | /* | 2 | /* |
2 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
3 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -12,12 +13,21 @@ | |||
12 | */ | 13 | */ |
13 | 14 | ||
14 | #include "includes.h" | 15 | #include "includes.h" |
15 | RCSID("$OpenBSD: buffer.c,v 1.23 2005/03/14 11:46:56 markus Exp $"); | 16 | |
17 | #include <sys/param.h> | ||
18 | |||
19 | #include <stdio.h> | ||
20 | #include <string.h> | ||
21 | #include <stdarg.h> | ||
16 | 22 | ||
17 | #include "xmalloc.h" | 23 | #include "xmalloc.h" |
18 | #include "buffer.h" | 24 | #include "buffer.h" |
19 | #include "log.h" | 25 | #include "log.h" |
20 | 26 | ||
27 | #define BUFFER_MAX_CHUNK 0x100000 | ||
28 | #define BUFFER_MAX_LEN 0xa00000 | ||
29 | #define BUFFER_ALLOCSZ 0x008000 | ||
30 | |||
21 | /* Initializes the buffer structure. */ | 31 | /* Initializes the buffer structure. */ |
22 | 32 | ||
23 | void | 33 | void |
@@ -66,6 +76,23 @@ buffer_append(Buffer *buffer, const void *data, u_int len) | |||
66 | memcpy(p, data, len); | 76 | memcpy(p, data, len); |
67 | } | 77 | } |
68 | 78 | ||
79 | static int | ||
80 | buffer_compact(Buffer *buffer) | ||
81 | { | ||
82 | /* | ||
83 | * If the buffer is quite empty, but all data is at the end, move the | ||
84 | * data to the beginning. | ||
85 | */ | ||
86 | if (buffer->offset > MIN(buffer->alloc, BUFFER_MAX_CHUNK)) { | ||
87 | memmove(buffer->buf, buffer->buf + buffer->offset, | ||
88 | buffer->end - buffer->offset); | ||
89 | buffer->end -= buffer->offset; | ||
90 | buffer->offset = 0; | ||
91 | return (1); | ||
92 | } | ||
93 | return (0); | ||
94 | } | ||
95 | |||
69 | /* | 96 | /* |
70 | * Appends space to the buffer, expanding the buffer if necessary. This does | 97 | * Appends space to the buffer, expanding the buffer if necessary. This does |
71 | * not actually copy the data into the buffer, but instead returns a pointer | 98 | * not actually copy the data into the buffer, but instead returns a pointer |
@@ -93,29 +120,43 @@ restart: | |||
93 | buffer->end += len; | 120 | buffer->end += len; |
94 | return p; | 121 | return p; |
95 | } | 122 | } |
96 | /* | 123 | |
97 | * If the buffer is quite empty, but all data is at the end, move the | 124 | /* Compact data back to the start of the buffer if necessary */ |
98 | * data to the beginning and retry. | 125 | if (buffer_compact(buffer)) |
99 | */ | ||
100 | if (buffer->offset > MIN(buffer->alloc, BUFFER_MAX_CHUNK)) { | ||
101 | memmove(buffer->buf, buffer->buf + buffer->offset, | ||
102 | buffer->end - buffer->offset); | ||
103 | buffer->end -= buffer->offset; | ||
104 | buffer->offset = 0; | ||
105 | goto restart; | 126 | goto restart; |
106 | } | ||
107 | /* Increase the size of the buffer and retry. */ | ||
108 | 127 | ||
109 | newlen = buffer->alloc + len + 32768; | 128 | /* Increase the size of the buffer and retry. */ |
129 | newlen = roundup(buffer->alloc + len, BUFFER_ALLOCSZ); | ||
110 | if (newlen > BUFFER_MAX_LEN) | 130 | if (newlen > BUFFER_MAX_LEN) |
111 | fatal("buffer_append_space: alloc %u not supported", | 131 | fatal("buffer_append_space: alloc %u not supported", |
112 | newlen); | 132 | newlen); |
113 | buffer->buf = xrealloc(buffer->buf, newlen); | 133 | buffer->buf = xrealloc(buffer->buf, 1, newlen); |
114 | buffer->alloc = newlen; | 134 | buffer->alloc = newlen; |
115 | goto restart; | 135 | goto restart; |
116 | /* NOTREACHED */ | 136 | /* NOTREACHED */ |
117 | } | 137 | } |
118 | 138 | ||
139 | /* | ||
140 | * Check whether an allocation of 'len' will fit in the buffer | ||
141 | * This must follow the same math as buffer_append_space | ||
142 | */ | ||
143 | int | ||
144 | buffer_check_alloc(Buffer *buffer, u_int len) | ||
145 | { | ||
146 | if (buffer->offset == buffer->end) { | ||
147 | buffer->offset = 0; | ||
148 | buffer->end = 0; | ||
149 | } | ||
150 | restart: | ||
151 | if (buffer->end + len < buffer->alloc) | ||
152 | return (1); | ||
153 | if (buffer_compact(buffer)) | ||
154 | goto restart; | ||
155 | if (roundup(buffer->alloc + len, BUFFER_ALLOCSZ) <= BUFFER_MAX_LEN) | ||
156 | return (1); | ||
157 | return (0); | ||
158 | } | ||
159 | |||
119 | /* Returns the number of bytes of data in the buffer. */ | 160 | /* Returns the number of bytes of data in the buffer. */ |
120 | 161 | ||
121 | u_int | 162 | u_int |