Resolves: #1949120 - ftp put failed with 'ftp: Out of memory' when stacksize set to unlimited

This commit is contained in:
Michal Ruprich 2021-04-21 15:52:03 +02:00
parent 28e192cb4c
commit 54938e721c
2 changed files with 35 additions and 1 deletions

View File

@ -1,7 +1,7 @@
Summary: The standard UNIX FTP (File Transfer Protocol) client Summary: The standard UNIX FTP (File Transfer Protocol) client
Name: ftp Name: ftp
Version: 0.17 Version: 0.17
Release: 87%{?dist} Release: 88%{?dist}
License: BSD with advertising License: BSD with advertising
Source0: ftp://ftp.linux.org.uk/pub/linux/Networking/netkit/netkit-ftp-%{version}.tar.gz Source0: ftp://ftp.linux.org.uk/pub/linux/Networking/netkit/netkit-ftp-%{version}.tar.gz
URL: ftp://ftp.linux.org.uk/pub/linux/Networking/netkit URL: ftp://ftp.linux.org.uk/pub/linux/Networking/netkit
@ -40,6 +40,7 @@ Patch32: netkit-ftp-0.17-lsn-timeout.patch
Patch33: netkit-ftp-0.17-getlogin.patch Patch33: netkit-ftp-0.17-getlogin.patch
Patch34: netkit-ftp-0.17-token.patch Patch34: netkit-ftp-0.17-token.patch
Patch35: netkit-ftp-0.17-linelen-segfault.patch Patch35: netkit-ftp-0.17-linelen-segfault.patch
Patch36: netkit-ftp-0.17-out-of-memory.patch
BuildRequires: glibc-devel, readline-devel, ncurses-devel BuildRequires: glibc-devel, readline-devel, ncurses-devel
BuildRequires: perl-interpreter, gcc BuildRequires: perl-interpreter, gcc
@ -90,6 +91,7 @@ file transfers.
%patch33 -p1 -b .getlogin %patch33 -p1 -b .getlogin
%patch34 -p1 -b .token %patch34 -p1 -b .token
%patch35 -p1 -b .linelen-segfault %patch35 -p1 -b .linelen-segfault
%patch36 -p1 -b .out-of-memory
%build %build
sh configure --with-c-compiler=%{__cc} --enable-ipv6 sh configure --with-c-compiler=%{__cc} --enable-ipv6
@ -119,6 +121,9 @@ make INSTALLROOT=${RPM_BUILD_ROOT} install
%{_mandir}/man5/netrc.* %{_mandir}/man5/netrc.*
%changelog %changelog
* Wed Apr 21 2021 Michal Ruprich <mruprich@redhat.com> - 0.17-88
- Resolves: #1949120 - ftp put failed with 'ftp: Out of memory' when stacksize set to unlimited
* Thu Apr 15 2021 Mohan Boddu <mboddu@redhat.com> - 0.17-87 * Thu Apr 15 2021 Mohan Boddu <mboddu@redhat.com> - 0.17-87
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937 - Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937

View File

@ -0,0 +1,29 @@
diff -up netkit-ftp-0.17/ftp/glob.c.arg_max1 netkit-ftp-0.17/ftp/glob.c
--- netkit-ftp-0.17/ftp/glob.c.arg_max1 2012-01-24 12:59:09.335021131 +0100
+++ netkit-ftp-0.17/ftp/glob.c 2012-01-24 13:05:27.752028732 +0100
@@ -55,10 +55,15 @@ char glob_rcsid[] =
#include "ftp_var.h" /* for protos only */
#include "glob.h"
+#ifndef LOWEST_ARG_MAX
+ #define LOWEST_ARG_MAX 2621440 /* ARG_MAX for default stack size limit 10240 */
+#endif
+
#define QUOTE 0200
#define TRIM 0177
#define eq(a,b) (strcmp(a, b)==0)
-#define GAVSIZ (sysconf(_SC_ARG_MAX)/6)
+#define max(a,b) (a > b ? a : b)
+#define GAVSIZ (max((int)sysconf(_SC_ARG_MAX), LOWEST_ARG_MAX)/6)
#define isdir(d) ((d.st_mode & S_IFMT) == S_IFDIR)
const char *globerr;
@@ -159,7 +164,7 @@ ginit(entry *agargv)
gargv = agargv;
sortbas = agargv;
gargc = 0;
- gnleft = sysconf(_SC_ARG_MAX) - 4;
+ gnleft = max((int)sysconf(_SC_ARG_MAX), LOWEST_ARG_MAX) - 4;
}
static