aboutsummaryrefslogtreecommitdiff
path: root/ftp
diff options
context:
space:
mode:
authorGanael LAPLANCHE <martymac@FreeBSD.org>2020-01-15 11:04:11 +0000
committerGanael LAPLANCHE <martymac@FreeBSD.org>2020-01-15 11:04:11 +0000
commita40473d025a33e45c71d5a4f5a56b5781a674e3f (patch)
treee4d65b7dd267848f0bf913677a5d835165a5e0f5 /ftp
parente34ef5ef29939c675717201e0faef1429e29fef3 (diff)
downloadports-a40473d025a33e45c71d5a4f5a56b5781a674e3f.tar.gz
ports-a40473d025a33e45c71d5a4f5a56b5781a674e3f.zip
Fix segmentation fault at startup when IPv6 is enabled
Backport commit 5d34493 from upstream. PR: 243307 Submitted by: Victor Sudakov <vas@sibptus.ru> Obtained from: Github <https://github.com/lavv17/lftp/commit/5d344937d60380341c20409c11f135afb630d7ee> MFH: 2020Q1
Notes
Notes: svn path=/head/; revision=523101
Diffstat (limited to 'ftp')
-rw-r--r--ftp/lftp/Makefile1
-rw-r--r--ftp/lftp/files/patch-5d34493.txt102
2 files changed, 103 insertions, 0 deletions
diff --git a/ftp/lftp/Makefile b/ftp/lftp/Makefile
index 75fcda5de246..dadf23a98dba 100644
--- a/ftp/lftp/Makefile
+++ b/ftp/lftp/Makefile
@@ -3,6 +3,7 @@
PORTNAME= lftp
PORTVERSION= 4.9.0
+PORTREVISION= 1
CATEGORIES= ftp
MASTER_SITES= http://lftp.tech/ftp/ \
http://lftp.tech/ftp/old/ \
diff --git a/ftp/lftp/files/patch-5d34493.txt b/ftp/lftp/files/patch-5d34493.txt
new file mode 100644
index 000000000000..1f09d7fa28d1
--- /dev/null
+++ b/ftp/lftp/files/patch-5d34493.txt
@@ -0,0 +1,102 @@
+commit 5d344937d60380341c20409c11f135afb630d7ee
+Author: Alexander V. Lukyanov <lavv17f@gmail.com>
+Date: Sat Jan 11 19:20:46 2020 +0300
+
+ check for ipv6 in resolver to avoid global init order problems (fix #557, fix #562)
+
+diff --git a/src/Resolver.cc b/src/Resolver.cc
+index 0332d5be..4e119966 100644
+--- src/Resolver.cc
++++ src/Resolver.cc
+@@ -355,6 +355,19 @@ int Resolver::FindAddressFamily(const char *name)
+ return -1;
+ }
+
++bool Resolver::IsAddressFamilySupporded(int af)
++{
++#if INET6
++ // check if ipv6 is really supported
++ if(af==AF_INET6 && (!FindGlobalIPv6Address() || !CanCreateIpv6Socket()))
++ {
++ LogNote(4, "IPv6 is not supported or configured");
++ return false;
++ }
++#endif // INET6
++ return true;
++}
++
+ void Resolver::ParseOrder(const char *s,int *o)
+ {
+ const char * const delim="\t ";
+@@ -364,7 +377,7 @@ void Resolver::ParseOrder(const char *s,int *o)
+ for(s1=strtok(s1,delim); s1; s1=strtok(0,delim))
+ {
+ int af=FindAddressFamily(s1);
+- if(af!=-1 && idx<15)
++ if(af!=-1 && idx<15 && IsAddressFamilySupporded(af))
+ {
+ if(o) o[idx]=af;
+ idx++;
+diff --git a/src/Resolver.h b/src/Resolver.h
+index 724714d9..18eeed42 100644
+--- src/Resolver.h
++++ src/Resolver.h
+@@ -26,7 +26,7 @@
+ #include "Cache.h"
+ #include "network.h"
+
+-class Resolver : public SMTask, protected ProtoLog
++class Resolver : public SMTask, protected ProtoLog, protected Networker
+ {
+ xstring hostname;
+ xstring portname;
+@@ -53,6 +53,7 @@ class Resolver : public SMTask, protected ProtoLog
+ void DoGethostbyname();
+
+ static int FindAddressFamily(const char *name);
++ static bool IsAddressFamilySupporded(int af);
+ static void ParseOrder(const char *s,int *o);
+
+ void LookupOne(const char *name);
+diff --git a/src/network.cc b/src/network.cc
+index e54076de..ea1b02eb 100644
+--- src/network.cc
++++ src/network.cc
+@@ -454,7 +454,7 @@ const char *Networker::FindGlobalIPv6Address()
+ return 0;
+ }
+
+-static bool CanCreateIpv6Socket()
++bool Networker::CanCreateIpv6Socket()
+ {
+ #if INET6
+ bool can=true;
+@@ -472,16 +472,3 @@ static bool CanCreateIpv6Socket()
+ return false;
+ #endif
+ }
+-
+-static struct NetworkInit : private Networker {
+- NetworkInit();
+-} NETWORK_INIT;
+-
+-NetworkInit::NetworkInit()
+-{
+-#if INET6
+- // check if ipv6 is really supported
+- if(!Networker::FindGlobalIPv6Address() || !CanCreateIpv6Socket())
+- ResMgr::Set("dns:order",0,"inet");
+-#endif // INET6
+-}
+diff --git a/src/network.h b/src/network.h
+index 3223ce82..e4ede6ef 100644
+--- src/network.h
++++ src/network.h
+@@ -140,6 +140,7 @@ protected:
+ static int SocketCreateUnboundTCP(int af,const char *hostname);
+ static void SocketSinglePF(int sock,int pf);
+ static const char *FindGlobalIPv6Address();
++ static bool CanCreateIpv6Socket();
+ };
+
+ #endif //NETWORK_H