summaryrefslogtreecommitdiff
path: root/readconf.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2010-06-26 09:50:30 +1000
committerDamien Miller <djm@mindrot.org>2010-06-26 09:50:30 +1000
commit232cfb1b1d0dccee68b1d433e0b4e1aa74919fc9 (patch)
tree80907fc629d104e69a7886cff390cabfba077e7b /readconf.c
parentd834d3583427981a395f8fc53346f9473b2e902c (diff)
- djm@cvs.openbsd.org 2010/06/25 07:14:46
[channels.c mux.c readconf.c readconf.h ssh.h] bz#1327: remove hardcoded limit of 100 permitopen clauses and port forwards per direction; ok markus@ stevesk@
Diffstat (limited to 'readconf.c')
-rw-r--r--readconf.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/readconf.c b/readconf.c
index 4bc98b77e..aae9cef4b 100644
--- a/readconf.c
+++ b/readconf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: readconf.c,v 1.184 2010/05/16 12:55:51 markus Exp $ */ 1/* $OpenBSD: readconf.c,v 1.185 2010/06/25 07:14:46 djm 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
@@ -255,8 +255,9 @@ add_local_forward(Options *options, const Forward *newfwd)
255 if (newfwd->listen_port < IPPORT_RESERVED && original_real_uid != 0) 255 if (newfwd->listen_port < IPPORT_RESERVED && original_real_uid != 0)
256 fatal("Privileged ports can only be forwarded by root."); 256 fatal("Privileged ports can only be forwarded by root.");
257#endif 257#endif
258 if (options->num_local_forwards >= SSH_MAX_FORWARDS_PER_DIRECTION) 258 options->local_forwards = xrealloc(options->local_forwards,
259 fatal("Too many local forwards (max %d).", SSH_MAX_FORWARDS_PER_DIRECTION); 259 options->num_local_forwards + 1,
260 sizeof(*options->local_forwards));
260 fwd = &options->local_forwards[options->num_local_forwards++]; 261 fwd = &options->local_forwards[options->num_local_forwards++];
261 262
262 fwd->listen_host = newfwd->listen_host; 263 fwd->listen_host = newfwd->listen_host;
@@ -274,9 +275,10 @@ void
274add_remote_forward(Options *options, const Forward *newfwd) 275add_remote_forward(Options *options, const Forward *newfwd)
275{ 276{
276 Forward *fwd; 277 Forward *fwd;
277 if (options->num_remote_forwards >= SSH_MAX_FORWARDS_PER_DIRECTION) 278
278 fatal("Too many remote forwards (max %d).", 279 options->remote_forwards = xrealloc(options->remote_forwards,
279 SSH_MAX_FORWARDS_PER_DIRECTION); 280 options->num_remote_forwards + 1,
281 sizeof(*options->remote_forwards));
280 fwd = &options->remote_forwards[options->num_remote_forwards++]; 282 fwd = &options->remote_forwards[options->num_remote_forwards++];
281 283
282 fwd->listen_host = newfwd->listen_host; 284 fwd->listen_host = newfwd->listen_host;
@@ -296,12 +298,20 @@ clear_forwardings(Options *options)
296 xfree(options->local_forwards[i].listen_host); 298 xfree(options->local_forwards[i].listen_host);
297 xfree(options->local_forwards[i].connect_host); 299 xfree(options->local_forwards[i].connect_host);
298 } 300 }
301 if (options->num_local_forwards > 0) {
302 xfree(options->local_forwards);
303 options->local_forwards = NULL;
304 }
299 options->num_local_forwards = 0; 305 options->num_local_forwards = 0;
300 for (i = 0; i < options->num_remote_forwards; i++) { 306 for (i = 0; i < options->num_remote_forwards; i++) {
301 if (options->remote_forwards[i].listen_host != NULL) 307 if (options->remote_forwards[i].listen_host != NULL)
302 xfree(options->remote_forwards[i].listen_host); 308 xfree(options->remote_forwards[i].listen_host);
303 xfree(options->remote_forwards[i].connect_host); 309 xfree(options->remote_forwards[i].connect_host);
304 } 310 }
311 if (options->num_remote_forwards > 0) {
312 xfree(options->remote_forwards);
313 options->remote_forwards = NULL;
314 }
305 options->num_remote_forwards = 0; 315 options->num_remote_forwards = 0;
306 options->tun_open = SSH_TUNMODE_NO; 316 options->tun_open = SSH_TUNMODE_NO;
307} 317}
@@ -1048,7 +1058,9 @@ initialize_options(Options * options)
1048 options->user_hostfile = NULL; 1058 options->user_hostfile = NULL;
1049 options->system_hostfile2 = NULL; 1059 options->system_hostfile2 = NULL;
1050 options->user_hostfile2 = NULL; 1060 options->user_hostfile2 = NULL;
1061 options->local_forwards = NULL;
1051 options->num_local_forwards = 0; 1062 options->num_local_forwards = 0;
1063 options->remote_forwards = NULL;
1052 options->num_remote_forwards = 0; 1064 options->num_remote_forwards = 0;
1053 options->clear_forwardings = -1; 1065 options->clear_forwardings = -1;
1054 options->log_level = SYSLOG_LEVEL_NOT_SET; 1066 options->log_level = SYSLOG_LEVEL_NOT_SET;