summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2005-03-01 21:24:33 +1100
committerDamien Miller <djm@mindrot.org>2005-03-01 21:24:33 +1100
commitf91ee4c3def4de8b4b9409f07ab26a61e535e1e6 (patch)
tree92d9f883c3c34f0d80b49a7855dcc2514798cf02 /misc.c
parent1717fd422f2c5691d745a7daf6908df9a6458904 (diff)
- djm@cvs.openbsd.org 2005/03/01 10:09:52
[auth-options.c channels.c channels.h clientloop.c compat.c compat.h] [misc.c misc.h readconf.c readconf.h servconf.c ssh.1 ssh.c ssh_config.5] [sshd_config.5] bz#413: allow optional specification of bind address for port forwardings. Patch originally by Dan Astorian, but worked on by several people Adds GatewayPorts=clientspecified option on server to allow remote forwards to bind to client-specified ports.
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c44
1 files changed, 43 insertions, 1 deletions
diff --git a/misc.c b/misc.c
index a90125505..2e366f81b 100644
--- a/misc.c
+++ b/misc.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: misc.c,v 1.27 2004/12/11 01:48:56 dtucker Exp $"); 26RCSID("$OpenBSD: misc.c,v 1.28 2005/03/01 10:09:52 djm Exp $");
27 27
28#include "misc.h" 28#include "misc.h"
29#include "log.h" 29#include "log.h"
@@ -275,6 +275,48 @@ convtime(const char *s)
275 return total; 275 return total;
276} 276}
277 277
278/*
279 * Search for next delimiter between hostnames/addresses and ports.
280 * Argument may be modified (for termination).
281 * Returns *cp if parsing succeeds.
282 * *cp is set to the start of the next delimiter, if one was found.
283 * If this is the last field, *cp is set to NULL.
284 */
285char *
286hpdelim(char **cp)
287{
288 char *s, *old;
289
290 if (cp == NULL || *cp == NULL)
291 return NULL;
292
293 old = s = *cp;
294 if (*s == '[') {
295 if ((s = strchr(s, ']')) == NULL)
296 return NULL;
297 else
298 s++;
299 } else if ((s = strpbrk(s, ":/")) == NULL)
300 s = *cp + strlen(*cp); /* skip to end (see first case below) */
301
302 switch (*s) {
303 case '\0':
304 *cp = NULL; /* no more fields*/
305 break;
306
307 case ':':
308 case '/':
309 *s = '\0'; /* terminate */
310 *cp = s + 1;
311 break;
312
313 default:
314 return NULL;
315 }
316
317 return old;
318}
319
278char * 320char *
279cleanhostname(char *host) 321cleanhostname(char *host)
280{ 322{