From 9b2fbda53853ae651349f97bcf86c891cc137f92 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Mon, 9 Mar 2009 13:01:08 +0000 Subject: ftpd: EPSV and SIZE support. Tested to work on IPv6 too. libbb: str2sockaddr shuld accept [IPv6] addr without port - wget 'ftp://[::1]/file' needs that to work. function old new delta bind_for_passive_mode - 129 +129 get_nport - 30 +30 ftpd_main 1731 1760 +29 str2sockaddr 412 431 +19 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 2/0 up/down: 207/0) Total: 207 bytes text data bss dec hex filename 808568 476 7864 816908 c770c busybox_old 808804 476 7864 817144 c77f8 busybox_unstripped --- libbb/xconnect.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'libbb/xconnect.c') diff --git a/libbb/xconnect.c b/libbb/xconnect.c index 975844500..f5d7983a4 100644 --- a/libbb/xconnect.c +++ b/libbb/xconnect.c @@ -167,7 +167,8 @@ USE_FEATURE_IPV6(sa_family_t af,) /* Even uglier parsing of [xx]:nn */ host++; cp = strchr(host, ']'); - if (!cp || cp[1] != ':') { /* Malformed: must have [xx]:nn */ + if (!cp || (cp[1] != ':' && cp[1] != '\0')) { + /* Malformed: must be [xx]:nn or [xx] */ bb_error_msg("bad address '%s'", org_host); if (ai_flags & DIE_ON_ERROR) xfunc_die(); @@ -183,8 +184,11 @@ USE_FEATURE_IPV6(sa_family_t af,) if (cp) { /* points to ":" or "]:" */ int sz = cp - host + 1; host = safe_strncpy(alloca(sz), host, sz); - if (ENABLE_FEATURE_IPV6 && *cp != ':') + if (ENABLE_FEATURE_IPV6 && *cp != ':') { cp++; /* skip ']' */ + if (*cp == '\0') /* [xx] without port */ + goto skip; + } cp++; /* skip ':' */ port = bb_strtou(cp, NULL, 10); if (errno || (unsigned)port > 0xffff) { @@ -193,6 +197,7 @@ USE_FEATURE_IPV6(sa_family_t af,) xfunc_die(); return NULL; } + skip: ; } memset(&hint, 0 , sizeof(hint)); -- cgit v1.2.3