diff options
author | Clint Adams <clint@users.sourceforge.net> | 2007-07-12 03:09:12 +0000 |
---|---|---|
committer | Clint Adams <clint@users.sourceforge.net> | 2007-07-12 03:09:12 +0000 |
commit | 01ba47bd4fc59c66b98301186cac7bc64c89404a (patch) | |
tree | 386b6e1a707d4949e66f6cbc3b04ccd40b2698a6 /Src/Modules/zftp.c | |
parent | a5187bb6ac96cc43f68367c5dc9332854c250713 (diff) | |
download | zsh-01ba47bd4fc59c66b98301186cac7bc64c89404a.tar.gz zsh-01ba47bd4fc59c66b98301186cac7bc64c89404a.tar.xz zsh-01ba47bd4fc59c66b98301186cac7bc64c89404a.zip |
revert that
Diffstat (limited to 'Src/Modules/zftp.c')
-rw-r--r-- | Src/Modules/zftp.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/Src/Modules/zftp.c b/Src/Modules/zftp.c index 9f810f922..af48e80aa 100644 --- a/Src/Modules/zftp.c +++ b/Src/Modules/zftp.c @@ -1697,12 +1697,12 @@ zftp_open(char *name, char **args, int flags) { struct protoent *zprotop; struct servent *zservp; - struct addrinfo *zai; + struct hostent *zhostp; char **addrp, *fname, *tmpptr, *portnam = "ftp"; char *hostnam, *hostsuffix; int err, tmout, port = -1; ZSOCKLEN_T len; - int af, hlen; + int herrno, af, hlen; if (!*args) { if (zfsess->userparams) @@ -1806,20 +1806,21 @@ zftp_open(char *name, char **args, int flags) #endif { off_t tcp_port; - struct addrinfo hints, *hostlist; - int gai_err; - hints.ai_family = af; - - gai_err = getaddrinfo(hostnam, NULL, &hints, &hostlist); - - if (errflag || gai_err) { + zhostp = zsh_getipnodebyname(hostnam, af, 0, &herrno); + if (!zhostp || errflag) { + /* should use herror() here if available, but maybe + * needs configure test. on AIX it's present but not + * in headers. + * + * on the other hand, herror() is obsolete + */ FAILED(); - zwarnnam(name, "host lookup failure: %s", gai_strerror(gai_err)); + zwarnnam(name, "host not found: %s", hostnam); alarm(0); return 1; } - zfsetparam("ZFTP_HOST", ztrdup(hostlist->ai_canonname), ZFPM_READONLY); + zfsetparam("ZFTP_HOST", ztrdup(zhostp->h_name), ZFPM_READONLY); /* careful with pointer types */ #if defined(HAVE_NTOHS) && defined(HAVE_HTONS) tcp_port = (off_t)ntohs((unsigned short)zservp->s_port); @@ -1844,6 +1845,7 @@ zftp_open(char *name, char **args, int flags) tcp_close(zfsess->control); zfsess->control = NULL; } + freehostent(zhostp); zfunsetparam("ZFTP_HOST"); zfunsetparam("ZFTP_PORT"); FAILED(); @@ -1862,16 +1864,17 @@ zftp_open(char *name, char **args, int flags) err = 1; /* try all possible IP's */ - for (zai = hostlist; err && zai; zai = zai->ai_next) { - if(hlen != zai->ai_addrlen) + for (addrp = zhostp->h_addr_list; err && *addrp; addrp++) { + if(hlen != zhostp->h_length) zwarnnam(name, "address length mismatch"); do { - err = tcp_connect(zfsess->control, zai); + err = tcp_connect(zfsess->control, *addrp, zhostp, zservp->s_port); } while (err && errno == EINTR && !errflag); /* you can check whether it's worth retrying here */ } if (err) { + freehostent(zhostp); zfclose(0); FAILED(); zwarnnam(name, "connect failed: %e", errno); @@ -1892,6 +1895,7 @@ zftp_open(char *name, char **args, int flags) zsh_inet_ntop(af, *addrp, pbuf, sizeof(pbuf)); zfsetparam("ZFTP_IP", ztrdup(pbuf), ZFPM_READONLY); } + freehostent(zhostp); /* now we can talk to the control connection */ zcfinish = 0; |