[Patch] ipv6 args
Matt Johnston
matt at ucc.asn.au
Thu May 21 19:42:01 WST 2009
Hi.
Thanks for the patch (sorry for the slow response to other
mail) - I'll test it out and apply for the next release.
Cheers,
Matt
On Thu, May 21, 2009 at 11:08:14AM +0200, freddy.dsx at free.fr wrote:
> Hello,
>
> With -p dropbear can listenning on [addresse:port], but it fail with
> ipv6 addresses. This patch try to handle ipv4, ipv6, ipv4:port and
> ipv6+port.
>
> The syntaxe [ipv6]:port come from openssh.
>
> Work fine with dropbear 0.52 on FreeBSD 7.2 and openwrt 8.09.
>
> --- dropbear-0.52.orig/svr-runopts.c Wed May 13 20:56:03 2009
> +++ dropbear-0.52/svr-runopts.c Wed May 13 22:20:22 2009
> @@ -311,27 +311,39 @@
> static void addportandaddress(char* spec) {
>
> char *myspec = NULL;
> + char *p = NULL;
>
> if (svr_opts.portcount < DROPBEAR_MAX_PORTS) {
>
> /* 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] = strchr(myspec, ':');
> -
> - if (svr_opts.ports[svr_opts.portcount] == NULL) {
> - /* no ':' -> the whole string specifies just a port */
> - svr_opts.ports[svr_opts.portcount] = myspec;
> - } else {
> - /* Split the address/port */
> - svr_opts.ports[svr_opts.portcount][0] = '\0';
> - svr_opts.ports[svr_opts.portcount]++;
> + /* [ipv6]:port */
> + if (myspec[0] == '[' && (p = strchr(myspec, ']')) != NULL && *(p+1) == ':') {
> + *p = '\0';
> + p+=2;
> + myspec++;
> + svr_opts.ports[svr_opts.portcount] = p;
> svr_opts.addresses[svr_opts.portcount] = myspec;
> - }
> -
> - if (svr_opts.addresses[svr_opts.portcount] == NULL) {
> - /* no address given -> fill in the default address */
> + } else if ((p = strchr(myspec, '.')) != NULL) {
> + if ((p = strchr(p, ':')) == NULL) {
> + /* ipv4 */
> + svr_opts.ports[svr_opts.portcount] = m_strdup(DROPBEAR_DEFPORT);
> + svr_opts.addresses[svr_opts.portcount] = myspec;
> + } else {
> + /* ipv4:port */
> + *p = '\0';
> + p++;
> + svr_opts.ports[svr_opts.portcount] = p;
> + svr_opts.addresses[svr_opts.portcount] = myspec;
> + }
> + } else if ((p = strchr(myspec, ':')) != NULL && (p = strchr(p, ':')) != NULL) {
> + /* ipv6 */
> + svr_opts.ports[svr_opts.portcount] = m_strdup(DROPBEAR_DEFPORT);
> + svr_opts.addresses[svr_opts.portcount] = myspec;
> + } else {
> + /* port */
> + svr_opts.ports[svr_opts.portcount] = myspec;
> svr_opts.addresses[svr_opts.portcount] = m_strdup(DROPBEAR_DEFADDRESS);
> }
>
> --
> Freddy DISSAUX <freddy.dsx+dropbear at free.fr>
>
More information about the Dropbear
mailing list