summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klausmann <klausman@gentoo.org>2021-01-22 13:30:34 +0100
committerTobias Klausmann <klausman@gentoo.org>2021-01-22 13:30:53 +0100
commit151740dee902b137e326f997a3e8486242b70b71 (patch)
tree6d3062261da91a29c0f3f987188d795862197bb8 /net-ftp/atftp
parentsys-auth/yubico-piv-tool: bump to 2.2.0 (diff)
downloadgentoo-151740dee902b137e326f997a3e8486242b70b71.tar.gz
gentoo-151740dee902b137e326f997a3e8486242b70b71.tar.bz2
gentoo-151740dee902b137e326f997a3e8486242b70b71.zip
net-ftp/atftp: Add patch that reduces # of seeks
Bug: https://bugs.gentoo.org/713672 Package-Manager: Portage-3.0.14, Repoman-3.0.2 Signed-off-by: Tobias Klausmann <klausman@gentoo.org>
Diffstat (limited to 'net-ftp/atftp')
-rw-r--r--net-ftp/atftp/atftp-0.7.2-r3.ebuild69
-rw-r--r--net-ftp/atftp/files/atftp-0.7.2-fewer_seeks.patch38
2 files changed, 107 insertions, 0 deletions
diff --git a/net-ftp/atftp/atftp-0.7.2-r3.ebuild b/net-ftp/atftp/atftp-0.7.2-r3.ebuild
new file mode 100644
index 000000000000..0b2c1e633f95
--- /dev/null
+++ b/net-ftp/atftp/atftp-0.7.2-r3.ebuild
@@ -0,0 +1,69 @@
+# Copyright 2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+inherit autotools flag-o-matic systemd
+
+DESCRIPTION="Advanced TFTP implementation client/server"
+HOMEPAGE="https://sourceforge.net/projects/atftp/"
+SRC_URI="mirror://sourceforge/atftp/${P}.tar.gz"
+
+LICENSE="GPL-2+"
+SLOT="0"
+KEYWORDS="~amd64 ~arm ~ppc ~ppc64 ~s390 ~sparc ~x86"
+IUSE="selinux tcpd readline pcre"
+
+DEPEND="tcpd? ( sys-apps/tcp-wrappers )
+ readline? ( sys-libs/readline:0= )
+ pcre? ( dev-libs/libpcre )"
+RDEPEND="${DEPEND}
+ !net-ftp/tftp-hpa
+ !net-ftp/uftpd
+ selinux? ( sec-policy/selinux-tftp )"
+BDEPEND=""
+
+PATCHES=(
+ "${FILESDIR}/${P}-CFLAGS.patch"
+ "${FILESDIR}/${P}-cve-2020-6097.patch"
+ "${FILESDIR}/${P}-fewer_seeks.patch"
+)
+
+src_prepare() {
+ append-cppflags -D_REENTRANT -DRATE_CONTROL
+ # fix #561720 by restoring pre-GCC5 inline semantics
+ append-cflags -std=gnu89
+
+ default
+ eautoreconf
+}
+
+src_configure() {
+ econf \
+ $(use_enable tcpd libwrap) \
+ $(use_enable readline libreadline) \
+ $(use_enable pcre libpcre) \
+ --enable-mtftp
+}
+
+src_test() {
+ cd "${S}"/test || die
+ # Try to run the tests
+ ./test.sh || die
+}
+
+src_install() {
+ default
+
+ newinitd "${FILESDIR}"/atftp.init atftp
+ newconfd "${FILESDIR}"/atftp.confd atftp
+
+ systemd_dounit "${FILESDIR}"/atftp.service
+ systemd_install_serviced "${FILESDIR}"/atftp.service.conf
+
+ dodoc README* BUGS FAQ Changelog INSTALL TODO
+ dodoc "${S}"/docs/*
+
+ docinto test
+ cd "${S}"/test || die
+ dodoc load.sh mtftp.conf pcre_pattern.txt test.sh test_suite.txt
+}
diff --git a/net-ftp/atftp/files/atftp-0.7.2-fewer_seeks.patch b/net-ftp/atftp/files/atftp-0.7.2-fewer_seeks.patch
new file mode 100644
index 000000000000..78926b94b9f7
--- /dev/null
+++ b/net-ftp/atftp/files/atftp-0.7.2-fewer_seeks.patch
@@ -0,0 +1,38 @@
+<F28>diff -U8 atftp-0.7.2/tftp_io.c /var/tmp/portage/net-ftp/atftp-0.7.2-r1/work/atftp-0.7.2/tftp_io.c
+--- atftp-0.7.2/tftp_io.c 2019-04-14 17:38:55.000000000 -0500
++++ /var/tmp/portage/net-ftp/atftp-0.7.2-r1/work/atftp-0.7.2/tftp_io.c 2020-03-16 12:55:22.371820662 -0500
+@@ -439,26 +439,32 @@
+ }
+
+ /*
+ * Write to file and do netascii conversion if needed
+ */
+ int tftp_file_write(FILE *fp, char *data_buffer, int data_buffer_size, long block_number, int data_size,
+ int convert, long *prev_block_number, int *temp)
+ {
++ static long filepos;
+ int bytes_written;
+ int c;
+ char prevchar = *temp;
+
+ if (!convert)
+ {
+ /* Simple case, just seek and write */
+- if (fseek(fp, (block_number - 1) * data_buffer_size, SEEK_SET) != 0)
+- return 0;
++ long position = (block_number - 1)*data_buffer_size;
++ if (position != filepos)
++ if (fseek(fp, position, SEEK_SET) != 0)
++ return 0;
++ else
++ filepos = position;
+ bytes_written = fwrite(data_buffer, 1, data_size, fp);
++ filepos += bytes_written;
+ }
+ else if (block_number != *prev_block_number)
+ {
+ /*
+ * Same principle than for reading, but simpler since when client
+ * send same block twice there is no need to rewrite it to the
+ * file
+ */