Grab segv patch from Fedora, make sure we fixup the ssl port code since ipv6 changes...
authorMike Frysinger <vapier@gentoo.org>
Fri, 14 Oct 2005 05:44:14 +0000 (05:44 +0000)
committerMike Frysinger <vapier@gentoo.org>
Fri, 14 Oct 2005 05:44:14 +0000 (05:44 +0000)
Package-Manager: portage-2.0.53_rc5

net-ftp/ftp/ChangeLog
net-ftp/ftp/Manifest
net-ftp/ftp/files/digest-ftp-0.17-r6 [new file with mode: 0644]
net-ftp/ftp/files/netkit-ftp-0.17-dont-strcpy-overlapping.patch [new file with mode: 0644]
net-ftp/ftp/files/netkit-ftp-0.17-ipv6.patch
net-ftp/ftp/files/netkit-ftp-0.17-segv.patch [new file with mode: 0644]
net-ftp/ftp/ftp-0.17-r6.ebuild [new file with mode: 0644]

index c6ed42ced23abfc1295ca6fad67d30d2c57d02e3..67ba5921a4f14d5f438b1b4e842cea428da7ae3f 100644 (file)
@@ -1,6 +1,16 @@
 # ChangeLog for net-ftp/ftp
 # Copyright 1999-2005 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/net-ftp/ftp/ChangeLog,v 1.20 2005/08/03 23:30:21 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/net-ftp/ftp/ChangeLog,v 1.21 2005/10/14 05:44:14 vapier Exp $
+
+*ftp-0.17-r6 (14 Oct 2005)
+
+  14 Oct 2005; Mike Frysinger <vapier@gentoo.org>
+  +files/netkit-ftp-0.17-dont-strcpy-overlapping.patch,
+  files/netkit-ftp-0.17-ipv6.patch, +files/netkit-ftp-0.17-segv.patch,
+  +ftp-0.17-r6.ebuild:
+  Grab segv patch from Fedora, make sure we fixup the ssl port code since ipv6
+  changes it, and fix a segfault when using strcpy() on the same areas of
+  memory #104311.
 
   03 Aug 2005; Mike Frysinger <vapier@gentoo.org> ftp-0.17-r5.ebuild:
   Make sure we build with LFS #101038 by Maik Musall.
index 383b8a4161a11381c1e85d30a69f203ab8d75829..f1d7a23df3685ac6117b5d992f09e2f1eba858f0 100644 (file)
@@ -1,3 +1,6 @@
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA1
+
 MD5 bfa2f8566ce2a75364c9aea8087b0270 ChangeLog 3642
 MD5 036b2200a177f3266c5cbb3f4d5e4ed5 files/digest-ftp-0.17-r3 66
 MD5 036b2200a177f3266c5cbb3f4d5e4ed5 files/digest-ftp-0.17-r5 66
@@ -17,3 +20,10 @@ MD5 80ca646c7ebf7d86e937294242836ea6 ftp-0.17-r3.ebuild 1034
 MD5 45fd632e8f4c81f73a7ab97dac005132 ftp-0.17-r5.ebuild 1413
 MD5 5de7cf5340f5972785e20645fe56ab32 ftp-0.17-r6.ebuild 1556
 MD5 9a09f8d531c582e78977dbfd96edc1f2 metadata.xml 164
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.2 (GNU/Linux)
+
+iD8DBQFDT0YxgIKl8Uu19MoRArd2AJ4g9rbZ4mz0zzoec3G4EAoI3qMljgCeLKBu
+I0tUl8k+OngUrLh320oYE5o=
+=KB4s
+-----END PGP SIGNATURE-----
diff --git a/net-ftp/ftp/files/digest-ftp-0.17-r6 b/net-ftp/ftp/files/digest-ftp-0.17-r6
new file mode 100644 (file)
index 0000000..d98bdd2
--- /dev/null
@@ -0,0 +1 @@
+MD5 94441610c9b86ef45c4c6ec609444060 netkit-ftp-0.17.tar.gz 53934
diff --git a/net-ftp/ftp/files/netkit-ftp-0.17-dont-strcpy-overlapping.patch b/net-ftp/ftp/files/netkit-ftp-0.17-dont-strcpy-overlapping.patch
new file mode 100644 (file)
index 0000000..dc08c87
--- /dev/null
@@ -0,0 +1,53 @@
+http://bugs.gentoo.org/104311
+
+From the strncpy(3) manpage:
+The strings may not overlap, and the destination string dest must be large 
+enough to receive the copy.
+
+ftp.c:1812:Bounds error: in strncpy with 0x4 for 63 and 0x4 for 1, source and destination objects overlap.
+ftp.c:1812:  Pointer value: 0x4
+ftp.c:1812:  Object `*proxstruct.3':
+ftp.c:1812:    Address in memory:    0x0 .. 0x7
+ftp.c:1812:    Size:                 8408 bytes
+ftp.c:1812:    Element size:         1 bytes
+ftp.c:1812:    Number of elements:   8408
+ftp.c:1812:    Storage class:        static
+Aborted
+
+The bug is hit when ftp.c's pswitch() is called multiple times:
+
+static struct comvars { char name[]; } proxstruct, tmpstruct;
+struct comvars *ip, *op;
+...
+if (flag) {
+       ip = &tmpstruct;
+       op = &proxstruct;
+} else {
+       ip = &proxstruct;
+       op = &tmpstruct;
+}
+...
+if (hostname)
+       strncpy(ip->name, hostname, sizeof(ip->name) - 1);
+...
+hostname = op->name;
+
+so if the code path is:
+       hostname = NULL
+       pswitch(0)
+       hostname = op->name (tmpstruct.name)
+       pswitch(1)
+       strncpy(ip->name (tmpstruct.name), hostname, ...)
+bad things happen
+
+--- ftp/ftp.c
++++ ftp/ftp.c
+@@ -1808,7 +1808,7 @@
+       }
+       ip->connect = connected;
+       connected = op->connect;
+-      if (hostname) {
++      if (hostname && ip->name != hostname) {
+               (void) strncpy(ip->name, hostname, sizeof(ip->name) - 1);
+               ip->name[sizeof(ip->name) - 1] = '\0';
+       } 
index defc6d1db0497d625f499a1ff27861ccd13d4fe6..8d6279d1fbbe765f095d72f3723a158d9d203404 100644 (file)
@@ -105,6 +105,26 @@ http://bugs.gentoo.org/show_bug.cgi?id=47507
        if (argc > 2) {
  #ifdef USE_SSL
                  /* not really an SSL enhancement but something that
+@@ -222,7 +222,7 @@
+                    * the default (unofficial) port number
+                    */
+                   if ((strcmp(argv[2],"ssl-ftp")==0) && (destsp==NULL))
+-                      port = 150;
++                      port = "150";
+                   else {
+                       if (destsp == NULL ) {
+                           printf("%s: bad port name-- %s\n",argv[1],argv[2]);
+@@ -230,7 +230,9 @@
+                           code = -1;
+                           return;
+                       } else {
+-                          port = ntohs(destsp->s_port);
++                          static char portbuf[10];
++                          snprintf(portbuf, sizeof(portbuf), "%i", ntohs(destsp->s_port));
++                          port = portbuf;
+                       }
+                   }
+               } else 
 @@ -233,20 +235,15 @@
                    }
                } else 
diff --git a/net-ftp/ftp/files/netkit-ftp-0.17-segv.patch b/net-ftp/ftp/files/netkit-ftp-0.17-segv.patch
new file mode 100644 (file)
index 0000000..53f0137
--- /dev/null
@@ -0,0 +1,90 @@
+Ripped from Fedora
+
+* Mon Jun 14 2004 Alan Cox <alan@redhat.com>
+- Re-arranged some totally bogus old bezerkly code that could
+  segfault ftp on connection loss. (BZ #122295)
+
+https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=122295
+
+--- netkit-ftp-0.17/ftp/ftp.c.segv     2004-06-14 11:04:38.000000000 -0400
++++ netkit-ftp-0.17/ftp/ftp.c  2004-06-14 11:06:46.000000000 -0400
+@@ -472,6 +472,8 @@
+                                       return (0);
+                               }
+                               lostpeer(0);
++                              fclose(cout);
++                              cout = NULL;
+                               if (verbose) {
+                                       printf("421 Service not available, remote server has closed connection\n");
+                                       (void) fflush(stdout);
+@@ -529,7 +531,14 @@
+                       cpend = 0;
+               (void) signal(SIGINT,oldintr);
+               if (code == 421 || originalcode == 421)
++              {
+                       lostpeer(0);
++                      if(cout)
++                      {
++                              fclose(cout);
++                              cout = NULL;
++                      }
++              }
+               if (abrtflag && oldintr != cmdabort && oldintr != SIG_IGN)
+                       (*oldintr)(SIGINT);
+               return (n - '0');
+@@ -1790,6 +1799,11 @@
+                       if (ptabflg)
+                               code = -1;
+                       lostpeer(0);
++                      if(cout != NULL)
++                      {
++                              fclose(cout);
++                              cout = NULL;
++                      }
+               }
+               (void) getreply(0);
+               (void) getreply(0);
+@@ -1815,6 +1829,11 @@
+                       perror("reset");
+                       code = -1;
+                       lostpeer(0);
++                      if(cout != NULL)
++                      {
++                              fclose(cout);
++                              cout = NULL;
++                      }
+               }
+               else if (nfnd) {
+                       (void) getreply(0);
+@@ -1897,6 +1916,11 @@
+               if (ptabflg)
+                       code = -1;
+               lostpeer(0);
++              if(cout != NULL)
++              {
++                      fclose(cout);
++                      cout = NULL;
++              }
+       }
+       if (din && FD_ISSET(fileno(din), &mask)) {
+               while (read(fileno(din), buf, BUFSIZ) > 0)
+--- netkit-ftp-0.17/ftp/main.c.segv    2004-06-14 11:03:18.000000000 -0400
++++ netkit-ftp-0.17/ftp/main.c 2004-06-14 11:03:42.000000000 -0400
+@@ -235,8 +235,6 @@
+       if (connected) {
+               if (cout != NULL) {
+                       shutdown(fileno(cout), 1+1);
+-                      fclose(cout);
+-                      cout = NULL;
+               }
+               if (data >= 0) {
+                       shutdown(data, 1+1);
+@@ -249,8 +247,6 @@
+       if (connected) {
+               if (cout != NULL) {
+                       shutdown(fileno(cout), 1+1);
+-                      fclose(cout);
+-                      cout = NULL;
+               }
+               connected = 0;
+       }
diff --git a/net-ftp/ftp/ftp-0.17-r6.ebuild b/net-ftp/ftp/ftp-0.17-r6.ebuild
new file mode 100644 (file)
index 0000000..dda4bbb
--- /dev/null
@@ -0,0 +1,52 @@
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-ftp/ftp/ftp-0.17-r6.ebuild,v 1.1 2005/10/14 05:44:14 vapier Exp $
+
+inherit eutils toolchain-funcs flag-o-matic
+
+MY_P=netkit-${P}
+S=${WORKDIR}/${MY_P}
+DESCRIPTION="Standard Linux FTP client"
+HOMEPAGE="http://www.hcs.harvard.edu/~dholland/computers/netkit.html"
+SRC_URI="ftp://ftp.uk.linux.org/pub/linux/Networking/netkit/${MY_P}.tar.gz"
+
+LICENSE="as-is"
+SLOT="0"
+KEYWORDS="-*" #~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
+IUSE="ssl ipv6"
+
+RDEPEND=">=sys-libs/ncurses-5.2
+       ssl? ( dev-libs/openssl )"
+DEPEND="${RDEPEND}
+       >=sys-apps/sed-4"
+
+src_unpack() {
+       unpack ${A}
+       cd "${S}"
+       epatch "${FILESDIR}"/${MY_P}-ssl-0.2.patch
+       epatch "${FILESDIR}"/${MY_P}-ipv6.patch #47507
+       epatch "${FILESDIR}"/${MY_P}-dont-strcpy-overlapping.patch #104311
+       epatch "${FILESDIR}"/${MY_P}-acct.patch #fedora
+       epatch "${FILESDIR}"/${MY_P}-locale.patch #fedora
+       epatch "${FILESDIR}"/${MY_P}-runique_mget.patch #fedora
+       epatch "${FILESDIR}"/${MY_P}-security.patch #fedora
+       epatch "${FILESDIR}"/${MY_P}-segv.patch #fedora
+       epatch "${FILESDIR}"/${MY_P}-custom-cflags.patch
+       append-lfs-flags #101038
+}
+
+src_compile() {
+       ./configure \
+               --prefix=/usr \
+               $(use_enable ssl) \
+               $(use_enable ipv6) \
+               ${EXTRA_ECONF} \
+               || die "configure failed"
+       emake CC="$(tc-getCC)" LDFLAGS="${LDFLAGS}" || die "make failed"
+}
+
+src_install() {
+       dobin ftp/ftp || die
+       doman ftp/ftp.1 ftp/netrc.5
+       dodoc ChangeLog README BUGS
+}