summaryrefslogtreecommitdiffhomepage
path: root/svr-runopts.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2013-03-19 20:55:11 +0800
committerMatt Johnston <matt@ucc.asn.au>2013-03-19 20:55:11 +0800
commit8393c5f0166dc456462e3c80126107346e1d1b7c (patch)
tree176bd32f2189fd63d2545d56938d71fbc4c7d21e /svr-runopts.c
parent5ff341206eff59a3d9762664c1b4c995fca81a4f (diff)
Allow specifying server "-p" options with ipv6 bracket notation,
patch from Ben Jencks
Diffstat (limited to 'svr-runopts.c')
-rw-r--r--svr-runopts.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/svr-runopts.c b/svr-runopts.c
index 1cd39ff..b1a54ee 100644
--- a/svr-runopts.c
+++ b/svr-runopts.c
@@ -329,8 +329,23 @@ static void addportandaddress(char* spec) {
/* We don't free it, it becomes part of the runopt state */
myspec = m_strdup(spec);
- /* search for ':', that separates address and port */
- svr_opts.ports[svr_opts.portcount] = strrchr(myspec, ':');
+ if (myspec[0] == '[') {
+ myspec++;
+ svr_opts.ports[svr_opts.portcount] = strchr(myspec, ']');
+ if (svr_opts.ports[svr_opts.portcount] == NULL) {
+ /* Unmatched [ -> exit */
+ dropbear_exit("Bad listen address");
+ }
+ svr_opts.ports[svr_opts.portcount][0] = '\0';
+ svr_opts.ports[svr_opts.portcount]++;
+ if (svr_opts.ports[svr_opts.portcount][0] != ':') {
+ /* Missing port -> exit */
+ dropbear_exit("Missing port");
+ }
+ } else {
+ /* search for ':', that separates address and port */
+ svr_opts.ports[svr_opts.portcount] = strrchr(myspec, ':');
+ }
if (svr_opts.ports[svr_opts.portcount] == NULL) {
/* no ':' -> the whole string specifies just a port */