@@ -0,0 +1,56 @@
--- 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);
 		}
 
