aboutsummaryrefslogtreecommitdiffstats
path: root/main/ncftp
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2016-03-22 16:26:17 +0200
committerTimo Teräs <timo.teras@iki.fi>2016-03-22 16:27:04 +0200
commitbdd2fccea55b6e7af9b2afd8ac5821d4d7ece65e (patch)
treeb65090fd27d733544bd4c3fd47fcf12105ae0f00 /main/ncftp
parentc6c357d2426bba4f2d70a7e4e097c40f142271fb (diff)
downloadaports-bdd2fccea55b6e7af9b2afd8ac5821d4d7ece65e.tar.bz2
aports-bdd2fccea55b6e7af9b2afd8ac5821d4d7ece65e.tar.xz
main/ncftp: remove alloca use
It's incorrect and can cause issues. This half of the fix for the ncftp bugs, the other part is musl issue. ref #5282
Diffstat (limited to 'main/ncftp')
-rw-r--r--main/ncftp/APKBUILD18
-rw-r--r--main/ncftp/remove-alloca-use.patch130
2 files changed, 139 insertions, 9 deletions
diff --git a/main/ncftp/APKBUILD b/main/ncftp/APKBUILD
index 483c4ac131..6be37f6768 100644
--- a/main/ncftp/APKBUILD
+++ b/main/ncftp/APKBUILD
@@ -1,7 +1,7 @@
# Maintainer: Carlo Landmeter <clandmeter@gmail.com>
pkgname=ncftp
pkgver=3.2.5
-pkgrel=5
+pkgrel=6
pkgdesc="A set of free application programs implementing FTP"
url="http://www.ncftp.com/"
arch="all"
@@ -9,15 +9,12 @@ license="custom"
depends=
makedepends="ncurses-dev"
install=""
-source="ftp://ftp.$pkgname.com/$pkgname/$pkgname-$pkgver-src.tar.bz2"
+source="ftp://ftp.$pkgname.com/$pkgname/$pkgname-$pkgver-src.tar.bz2
+ remove-alloca-use.patch"
subpackages="$pkgname-doc $pkgname-bookmarks"
_builddir="$srcdir/$pkgname-$pkgver"
-prepare() {
- mkdir -p "$pkgdir"/usr/share || return 1
-}
-
build () {
cd "$_builddir" || return 1
@@ -50,6 +47,9 @@ bookmarks () {
"$subpkgdir"/usr/bin/ || return 1
}
-md5sums="b05c7a6d5269c04891f02f43d4312b30 ncftp-3.2.5-src.tar.bz2"
-sha256sums="b4ebe2415761a5137cd1d313c8fc1352f26d8963cc9e9e354e29720aa2089d42 ncftp-3.2.5-src.tar.bz2"
-sha512sums="ebd7f618e5a9ac5e59f3e3dbf9b15765e80404416865212c0b2ee7339aafe2296867faf02fad2084e5a6377796e787d5cfc6599ec3f0e544c6b137734cfdc405 ncftp-3.2.5-src.tar.bz2"
+md5sums="b05c7a6d5269c04891f02f43d4312b30 ncftp-3.2.5-src.tar.bz2
+d13044a36fbd26473dc60ac8357262f6 remove-alloca-use.patch"
+sha256sums="b4ebe2415761a5137cd1d313c8fc1352f26d8963cc9e9e354e29720aa2089d42 ncftp-3.2.5-src.tar.bz2
+e2c22fbfe819f726de086098af6aeda9794ec7fabc1e41e65128ba061efceef4 remove-alloca-use.patch"
+sha512sums="ebd7f618e5a9ac5e59f3e3dbf9b15765e80404416865212c0b2ee7339aafe2296867faf02fad2084e5a6377796e787d5cfc6599ec3f0e544c6b137734cfdc405 ncftp-3.2.5-src.tar.bz2
+6d2256d12b4306f6cddaf47cf38c9cedcd6d37ee2b9c4243de5e661b51d8bc991d632754eef77a778890b0c0458ae59fc9a08f34c6901257bd863695d80c4de0 remove-alloca-use.patch"
diff --git a/main/ncftp/remove-alloca-use.patch b/main/ncftp/remove-alloca-use.patch
new file mode 100644
index 0000000000..0ed63e436f
--- /dev/null
+++ b/main/ncftp/remove-alloca-use.patch
@@ -0,0 +1,130 @@
+The alloca() use in sio is incorrect. gethostby*_r will make the hostent
+contain pointers to the submitted area, but when the function returns the
+alloca() allocated area is freed. Always use the supplied buffer.
+
+diff -ru ncftp-3.2.5.orig/sio/DNSUtil.c ncftp-3.2.5/sio/DNSUtil.c
+--- ncftp-3.2.5.orig/sio/DNSUtil.c 2009-10-24 02:31:23.000000000 +0300
++++ ncftp-3.2.5/sio/DNSUtil.c 2016-03-22 16:17:36.809816988 +0200
+@@ -50,6 +50,13 @@
+ errno = ENOENT;
+ break;
+ }
++#elif defined(HAVE_GETHOSTBYNAME_R) && defined(LINUX)
++ struct hostent *h;
++ int h_errno_unused = 0, r;
++ memset(hpbuf, 0, hpbufsize);
++ r = gethostbyname_r(name, hp, hpbuf, hpbufsize, &h, &h_errno_unused);
++ if (r == 0 && h != NULL)
++ return (0);
+ #elif defined(HAVE_GETHOSTBYNAME_R) && (defined(SOLARIS) || defined(IRIX) || defined(BSDOS))
+ struct hostent *h;
+ int h_errno_unused = 0;
+@@ -57,60 +64,6 @@
+ h = gethostbyname_r(name, hp, hpbuf, hpbufsize, &h_errno_unused);
+ if (h != NULL)
+ return (0);
+-#elif defined(HAVE_GETHOSTBYNAME2_R) && defined(LINUX) && defined(HAVE_ALLOCA)
+- char *usehpbuf;
+- struct hostent *h;
+- int my_h_errno, rc;
+-
+- usehpbuf = hpbuf;
+- forever {
+- errno = 0;
+- my_h_errno = 0;
+- h = NULL;
+- memset(usehpbuf, 0, hpbufsize);
+- rc = gethostbyname2_r(name, AF_INET, hp, usehpbuf, hpbufsize, &h, &my_h_errno);
+- if ((rc == 0) && (h != NULL))
+- return (0);
+- if ((rc == ERANGE) || ((rc == -1) && (errno == ERANGE))) {
+- hpbufsize *= 2;
+- usehpbuf = alloca(hpbufsize);
+- if (usehpbuf == NULL) {
+- errno = ENOMEM;
+- return (-1);
+- }
+- continue;
+- }
+- if ((rc == 0) && (my_h_errno != 0))
+- errno = ENOENT;
+- break;
+- }
+-#elif defined(HAVE_GETHOSTBYNAME_R) && defined(LINUX) && defined(HAVE_ALLOCA)
+- char *usehpbuf;
+- struct hostent *h;
+- int my_h_errno, rc;
+-
+- usehpbuf = hpbuf;
+- forever {
+- errno = 0;
+- my_h_errno = 0;
+- h = NULL;
+- memset(usehpbuf, 0, hpbufsize);
+- rc = gethostbyname_r(name, hp, usehpbuf, hpbufsize, &h, &my_h_errno);
+- if ((rc == 0) && (h != NULL))
+- return (0);
+- if ((rc == ERANGE) || ((rc == -1) && (errno == ERANGE))) {
+- hpbufsize *= 2;
+- usehpbuf = alloca(hpbufsize);
+- if (usehpbuf == NULL) {
+- errno = ENOMEM;
+- return (-1);
+- }
+- continue;
+- }
+- if ((rc == 0) && (my_h_errno != 0))
+- errno = ENOENT;
+- break;
+- }
+ #elif defined(HAVE_GETHOSTBYNAME_R) && defined(AIX)
+ struct hostent_data hed;
+ memset(hpbuf, 0, hpbufsize);
+@@ -152,6 +105,13 @@
+ return (-2);
+ return (0);
+ }
++#elif defined(HAVE_GETHOSTBYADDR_R) && defined(LINUX)
++ struct hostent *h;
++ int h_errno_unused = 0, r;
++ memset(hpbuf, 0, hpbufsize);
++ r = gethostbyaddr_r((const void *) addr, asize, atype, hp, hpbuf, hpbufsize, &h, &h_errno_unused);
++ if (r == 0 && h != NULL)
++ return (0);
+ #elif defined(HAVE_GETHOSTBYADDR_R) && (defined(SOLARIS) || defined(IRIX) || defined(BSDOS))
+ struct hostent *h;
+ int h_errno_unused = 0;
+@@ -159,33 +119,6 @@
+ h = gethostbyaddr_r((gethost_addrptr_t) addr, asize, atype, hp, hpbuf, hpbufsize, &h_errno_unused);
+ if (h != NULL)
+ return (0);
+-#elif defined(HAVE_GETHOSTBYADDR_R) && defined(LINUX) && defined(HAVE_ALLOCA)
+- char *usehpbuf;
+- struct hostent *h;
+- int my_h_errno, rc;
+-
+- usehpbuf = hpbuf;
+- forever {
+- errno = 0;
+- my_h_errno = 0;
+- h = NULL;
+- memset(usehpbuf, 0, hpbufsize);
+- rc = gethostbyaddr_r((gethost_addrptr_t) addr, asize, atype, hp, usehpbuf, hpbufsize, &h, &my_h_errno);
+- if ((rc == 0) && (h != NULL))
+- return (0);
+- if ((rc == ERANGE) || ((rc == -1) && (errno == ERANGE))) {
+- hpbufsize *= 2;
+- usehpbuf = alloca(hpbufsize);
+- if (usehpbuf == NULL) {
+- errno = ENOMEM;
+- return (-1);
+- }
+- continue;
+- }
+- if ((rc == 0) && (my_h_errno != 0))
+- errno = ENOENT;
+- break;
+- }
+ #elif defined(HAVE_GETHOSTBYADDR_R) && defined(AIX)
+ struct hostent_data hed;
+ memset(hpbuf, 0, hpbufsize);