MFH: r523101
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 <5d344937d6
>
Approved by: portmgr
This commit is contained in:
parent
9aab489596
commit
4594f6e0b3
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/branches/2020Q1/; revision=523247
@ -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/ \
|
||||
|
102
ftp/lftp/files/patch-5d34493.txt
Normal file
102
ftp/lftp/files/patch-5d34493.txt
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user