Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/ftp cope with 2553bis getnameinfo (always attach sco...



details:   https://anonhg.NetBSD.org/src/rev/a1bbd491433c
branches:  trunk
changeset: 499604:a1bbd491433c
user:      itojun <itojun%NetBSD.org@localhost>
date:      Fri Nov 24 13:01:24 2000 +0000

description:
cope with 2553bis getnameinfo (always attach scope id)
getnameinfo error check.

diffstat:

 usr.bin/ftp/ftp.c     |  30 ++++++++++++++++++------------
 usr.bin/ftp/version.h |   4 ++--
 2 files changed, 20 insertions(+), 14 deletions(-)

diffs (92 lines):

diff -r 8168b19296b1 -r a1bbd491433c usr.bin/ftp/ftp.c
--- a/usr.bin/ftp/ftp.c Fri Nov 24 12:58:17 2000 +0000
+++ b/usr.bin/ftp/ftp.c Fri Nov 24 13:01:24 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ftp.c,v 1.111 2000/11/15 04:09:19 itojun Exp $ */
+/*     $NetBSD: ftp.c,v 1.112 2000/11/24 13:01:24 itojun Exp $ */
 
 /*-
  * Copyright (c) 1996-2000 The NetBSD Foundation, Inc.
@@ -103,7 +103,7 @@
 #if 0
 static char sccsid[] = "@(#)ftp.c      8.6 (Berkeley) 10/27/94";
 #else
-__RCSID("$NetBSD: ftp.c,v 1.111 2000/11/15 04:09:19 itojun Exp $");
+__RCSID("$NetBSD: ftp.c,v 1.112 2000/11/24 13:01:24 itojun Exp $");
 #endif
 #endif /* not lint */
 
@@ -223,8 +223,9 @@
                if (res0->ai_next)      /* if we have multiple possibilities */
 #endif
                {
-                       getnameinfo(res->ai_addr, res->ai_addrlen,
-                           hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST);
+                       if (getnameinfo(res->ai_addr, res->ai_addrlen,
+                           hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST))
+                               strlcpy(hbuf, "?", sizeof(hbuf));
                        fprintf(ttyout, "Trying %s...\n", hbuf);
                }
                ((struct sockaddr_in *)res->ai_addr)->sin_port = htons(portnum);
@@ -240,9 +241,10 @@
                if (error) {
                        /* this "if" clause is to prevent print warning twice */
                        if (res->ai_next) {
-                               getnameinfo(res->ai_addr, res->ai_addrlen,
+                               if (getnameinfo(res->ai_addr, res->ai_addrlen,
                                    hbuf, sizeof(hbuf), NULL, 0,
-                                   NI_NUMERICHOST);
+                                   NI_NUMERICHOST))
+                                       strlcpy(hbuf, "?", sizeof(hbuf));
                                warn("connect to address %s", hbuf);
                        }
                        cause = "connect";
@@ -1609,8 +1611,9 @@
                warn("listen");
 
        if (sendport) {
-               char hname[NI_MAXHOST];
+               char hname[NI_MAXHOST], sname[NI_MAXSERV];
                int af;
+               struct sockinet tmp;
 
                switch (data_addr.su_family) {
                case AF_INET:
@@ -1623,13 +1626,16 @@
                case AF_INET6:
 #endif
                        af = (data_addr.su_family == AF_INET) ? 1 : 2;
-                       if (getnameinfo((struct sockaddr *)&data_addr.si_su,
-                           data_addr.su_len, hname, sizeof(hname), NULL, 0,
-                           NI_NUMERICHOST)) {
+                       tmp = data_addr;
+                       if (tmp.su_family == AF_INET6)
+                               tmp.si_su.su_sin6.sin6_scope_id = 0;
+                       if (getnameinfo((struct sockaddr *)&tmp.si_su,
+                           tmp.su_len, hname, sizeof(hname), sname,
+                           sizeof(sname), NI_NUMERICHOST | NI_NUMERICSERV)) {
                                result = ERROR;
                        } else {
-                               result = command("EPRT |%d|%s|%d|", af, hname,
-                                               ntohs(data_addr.su_port));
+                               result = command("EPRT |%d|%s|%s|", af, hname,
+                                   sname);
                                if (!connected)
                                        return (1);
                                if (result != COMPLETE) {
diff -r 8168b19296b1 -r a1bbd491433c usr.bin/ftp/version.h
--- a/usr.bin/ftp/version.h     Fri Nov 24 12:58:17 2000 +0000
+++ b/usr.bin/ftp/version.h     Fri Nov 24 13:01:24 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: version.h,v 1.22 2000/11/15 00:11:04 lukem Exp $       */
+/*     $NetBSD: version.h,v 1.23 2000/11/24 13:01:25 itojun Exp $      */
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -40,5 +40,5 @@
 #endif
 
 #ifndef FTP_VERSION
-#define        FTP_VERSION     "20001115"
+#define        FTP_VERSION     "20001124"
 #endif



Home | Main Index | Thread Index | Old Index