diff options
author | djm@openbsd.org <djm@openbsd.org> | 2016-04-06 08:42:17 +0200 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2016-04-08 06:26:06 +0200 |
commit | 0ccbd5eca0f0dd78e71a4b69c66f03a66908d558 (patch) | |
tree | d3b976a3f09569186f2a03d1b87c342432cd4f3c /misc.c | |
parent | upstream commit (diff) | |
download | openssh-0ccbd5eca0f0dd78e71a4b69c66f03a66908d558.tar.xz openssh-0ccbd5eca0f0dd78e71a4b69c66f03a66908d558.zip |
upstream commit
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@
Upstream-ID: 40a51d68b6300f1cc61deecdb7d4847b8b7b0de1
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 40 |
1 files changed, 39 insertions, 1 deletions
@@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.103 2016/04/02 14:37:42 krw Exp $ */ +/* $OpenBSD: misc.c,v 1.104 2016/04/06 06:42:17 djm Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2005,2006 Damien Miller. All rights reserved. @@ -1144,3 +1144,41 @@ sock_set_v6only(int s) error("setsockopt IPV6_V6ONLY: %s", strerror(errno)); #endif } + +/* + * Compares two strings that maybe be NULL. Returns non-zero if strings + * are both NULL or are identical, returns zero otherwise. + */ +static int +strcmp_maybe_null(const char *a, const char *b) +{ + if ((a == NULL && b != NULL) || (a != NULL && b == NULL)) + return 0; + if (a != NULL && strcmp(a, b) != 0) + return 0; + return 1; +} + +/* + * Compare two forwards, returning non-zero if they are identical or + * zero otherwise. + */ +int +forward_equals(const struct Forward *a, const struct Forward *b) +{ + if (strcmp_maybe_null(a->listen_host, b->listen_host) == 0) + return 0; + if (a->listen_port != b->listen_port) + return 0; + if (strcmp_maybe_null(a->listen_path, b->listen_path) == 0) + return 0; + if (strcmp_maybe_null(a->connect_host, b->connect_host) == 0) + return 0; + if (a->connect_port != b->connect_port) + return 0; + if (strcmp_maybe_null(a->connect_path, b->connect_path) == 0) + return 0; + /* allocated_port and handle are not checked */ + return 1; +} + |