# HG changeset patch # User Matt Johnston # Date 1363697711 -28800 # Node ID 002cf09827c08801b9dddbdfe3ed1ead3db3ca87 # Parent 2e573f39b88e7b03203dcf45c456dac9b196f538 Allow specifying server "-p" options with ipv6 bracket notation, patch from Ben Jencks diff -r 2e573f39b88e -r 002cf09827c0 svr-runopts.c --- a/svr-runopts.c Tue Mar 19 20:15:44 2013 +0800 +++ b/svr-runopts.c Tue Mar 19 20:55:11 2013 +0800 @@ -329,8 +329,23 @@ /* 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 */