diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2016-04-06 06:42:18 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2016-04-06 06:42:18 +0000 |
commit | f7299304b96a809e38af243ee3c416922034b597 (patch) | |
tree | 80436f0253d9fe2dc5bf36865e9f3a6e9dd7a803 /usr.bin/ssh/readconf.c | |
parent | c13124bee887f3bbe860cbc4414e93d32b5483ba (diff) |
don't record duplicate LocalForward and RemoteForward entries;
fixes failure with ExitOnForwardFailure+hostname canonicalisation
where the same forwards are added on the second pass through
the configuration file. bz#2562; ok dtucker@
Diffstat (limited to 'usr.bin/ssh/readconf.c')
-rw-r--r-- | usr.bin/ssh/readconf.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/usr.bin/ssh/readconf.c b/usr.bin/ssh/readconf.c index 0e2e9e0de46..91a8e00a463 100644 --- a/usr.bin/ssh/readconf.c +++ b/usr.bin/ssh/readconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: readconf.c,v 1.250 2016/02/08 23:40:12 djm Exp $ */ +/* $OpenBSD: readconf.c,v 1.251 2016/04/06 06:42:17 djm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -284,10 +284,16 @@ add_local_forward(Options *options, const struct Forward *newfwd) { struct Forward *fwd; extern uid_t original_real_uid; + int i; if (newfwd->listen_port < IPPORT_RESERVED && original_real_uid != 0 && newfwd->listen_path == NULL) fatal("Privileged ports can only be forwarded by root."); + /* Don't add duplicates */ + for (i = 0; i < options->num_local_forwards; i++) { + if (forward_equals(newfwd, options->local_forwards + i)) + return; + } options->local_forwards = xreallocarray(options->local_forwards, options->num_local_forwards + 1, sizeof(*options->local_forwards)); @@ -310,7 +316,13 @@ void add_remote_forward(Options *options, const struct Forward *newfwd) { struct Forward *fwd; + int i; + /* Don't add duplicates */ + for (i = 0; i < options->num_remote_forwards; i++) { + if (forward_equals(newfwd, options->remote_forwards + i)) + return; + } options->remote_forwards = xreallocarray(options->remote_forwards, options->num_remote_forwards + 1, sizeof(*options->remote_forwards)); |