diff options
Diffstat (limited to 'readconf.c')
-rw-r--r-- | readconf.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/readconf.c b/readconf.c index 69d4553af..c692f7dd2 100644 --- a/readconf.c +++ b/readconf.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: readconf.c,v 1.250 2016/02/08 23:40:12 djm Exp $ */ | 1 | /* $OpenBSD: readconf.c,v 1.251 2016/04/06 06:42:17 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 |
@@ -294,12 +294,19 @@ void | |||
294 | add_local_forward(Options *options, const struct Forward *newfwd) | 294 | add_local_forward(Options *options, const struct Forward *newfwd) |
295 | { | 295 | { |
296 | struct Forward *fwd; | 296 | struct Forward *fwd; |
297 | int i; | ||
297 | #ifndef NO_IPPORT_RESERVED_CONCEPT | 298 | #ifndef NO_IPPORT_RESERVED_CONCEPT |
298 | extern uid_t original_real_uid; | 299 | extern uid_t original_real_uid; |
300 | |||
299 | if (newfwd->listen_port < IPPORT_RESERVED && original_real_uid != 0 && | 301 | if (newfwd->listen_port < IPPORT_RESERVED && original_real_uid != 0 && |
300 | newfwd->listen_path == NULL) | 302 | newfwd->listen_path == NULL) |
301 | fatal("Privileged ports can only be forwarded by root."); | 303 | fatal("Privileged ports can only be forwarded by root."); |
302 | #endif | 304 | #endif |
305 | /* Don't add duplicates */ | ||
306 | for (i = 0; i < options->num_local_forwards; i++) { | ||
307 | if (forward_equals(newfwd, options->local_forwards + i)) | ||
308 | return; | ||
309 | } | ||
303 | options->local_forwards = xreallocarray(options->local_forwards, | 310 | options->local_forwards = xreallocarray(options->local_forwards, |
304 | options->num_local_forwards + 1, | 311 | options->num_local_forwards + 1, |
305 | sizeof(*options->local_forwards)); | 312 | sizeof(*options->local_forwards)); |
@@ -322,7 +329,13 @@ void | |||
322 | add_remote_forward(Options *options, const struct Forward *newfwd) | 329 | add_remote_forward(Options *options, const struct Forward *newfwd) |
323 | { | 330 | { |
324 | struct Forward *fwd; | 331 | struct Forward *fwd; |
332 | int i; | ||
325 | 333 | ||
334 | /* Don't add duplicates */ | ||
335 | for (i = 0; i < options->num_remote_forwards; i++) { | ||
336 | if (forward_equals(newfwd, options->remote_forwards + i)) | ||
337 | return; | ||
338 | } | ||
326 | options->remote_forwards = xreallocarray(options->remote_forwards, | 339 | options->remote_forwards = xreallocarray(options->remote_forwards, |
327 | options->num_remote_forwards + 1, | 340 | options->num_remote_forwards + 1, |
328 | sizeof(*options->remote_forwards)); | 341 | sizeof(*options->remote_forwards)); |