svn commit: r523101 - in head/ftp/lftp: . files
Ganael LAPLANCHE
martymac at FreeBSD.org
Wed Jan 15 11:04:12 UTC 2020
Author: martymac
Date: Wed Jan 15 11:04:11 2020
New Revision: 523101
URL: https://svnweb.freebsd.org/changeset/ports/523101
Log:
Fix segmentation fault at startup when IPv6 is enabled
Backport commit 5d34493 from upstream.
PR: 243307
Submitted by: Victor Sudakov <vas at sibptus.ru>
Obtained from: Github <https://github.com/lavv17/lftp/commit/5d344937d60380341c20409c11f135afb630d7ee>
MFH: 2020Q1
Added:
head/ftp/lftp/files/patch-5d34493.txt (contents, props changed)
Modified:
head/ftp/lftp/Makefile
Modified: head/ftp/lftp/Makefile
==============================================================================
--- head/ftp/lftp/Makefile Wed Jan 15 10:51:47 2020 (r523100)
+++ head/ftp/lftp/Makefile Wed Jan 15 11:04:11 2020 (r523101)
@@ -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/ \
Added: head/ftp/lftp/files/patch-5d34493.txt
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/ftp/lftp/files/patch-5d34493.txt Wed Jan 15 11:04:11 2020 (r523101)
@@ -0,0 +1,102 @@
+commit 5d344937d60380341c20409c11f135afb630d7ee
+Author: Alexander V. Lukyanov <lavv17f at 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
More information about the svn-ports-all
mailing list