summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenis Vlasenko2009-03-09 13:01:08 +0000
committerDenis Vlasenko2009-03-09 13:01:08 +0000
commit9b2fbda53853ae651349f97bcf86c891cc137f92 (patch)
tree23dd0fe4e01328899ba94e348a206ecb13ca37ac /libbb
parent57a3b174989c7778fb255f716e090d5be807b9b7 (diff)
downloadbusybox-9b2fbda53853ae651349f97bcf86c891cc137f92.zip
busybox-9b2fbda53853ae651349f97bcf86c891cc137f92.tar.gz
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
Diffstat (limited to 'libbb')
-rw-r--r--libbb/xconnect.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libbb/xconnect.c b/libbb/xconnect.c
index 9758445..f5d7983 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));