fix second find_cmd Segmentation fault

This commit is contained in:
chengyechun 2022-09-13 16:30:58 +08:00
parent 780e486ce5
commit c2686e9235
3 changed files with 134 additions and 1 deletions

View File

@ -0,0 +1,30 @@
From 40c20c587ed6435bb489f31c0aac94c2ca828f4a Mon Sep 17 00:00:00 2001
From: Kevin Adler <kadler@su.ibm.com>
Date: Sat, 23 Jul 2022 16:39:40 +0800
Subject: [PATCH] Ensure that PollVec enum matches poll values
Conflict:NA
Reference:https://github.com/lavv17/lftp/commit/40c20c587ed6435bb489f31c0aac94c2ca828f4a
---
src/PollVec.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/PollVec.h b/src/PollVec.h
index fda75a4..296f2f2 100644
--- a/src/PollVec.h
+++ b/src/PollVec.h
@@ -59,8 +59,8 @@ public:
void Block();
enum {
- IN=1,
- OUT=4,
+ IN=POLLIN,
+ OUT=POLLOUT,
};
void SetTimeout(const timeval &t) { tv_timeout=t; }
--
2.23.0

View File

@ -0,0 +1,94 @@
From 0ead378c8a19d4c7b86e35265a7f6e878fd63c0d Mon Sep 17 00:00:00 2001
From: "Alexander V. Lukyanov" <lavv17@gmail.com>
Date: Wed, 20 Apr 2022 23:32:37 +0300
Subject: [PATCH] fix second find_cmd Segmentation fault
Conflict:NA
Reference:https://github.com/lavv17/lftp/commit/0ead378c8a19d4c7b86e35265a7f6e878fd63c0d
---
src/GetFileInfo.cc | 34 +++++++++++++++++++++++-----------
src/GetFileInfo.h | 2 ++
2 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/src/GetFileInfo.cc b/src/GetFileInfo.cc
index 7afb3d8..4d08dfa 100644
--- a/src/GetFileInfo.cc
+++ b/src/GetFileInfo.cc
@@ -114,6 +114,22 @@ void GetFileInfo::PrepareToDie()
}
}
+void GetFileInfo::MakeVerifyFileName()
+{
+ /* Here we should have the home directory path. Find out
+ * the real name of the path. (we may have something like "~..".) */
+
+ FileAccess::Path pwd(session->GetCwd());
+
+ session->SetCwd(origdir);
+ session->Chdir(dir, false);
+
+ verify_fn.set(basename_ptr(session->GetCwd()));
+
+ /* go back */
+ session->SetCwd(pwd);
+}
+
int GetFileInfo::Do()
{
int res;
@@ -241,6 +257,8 @@ int GetFileInfo::Do()
if(!saved_error_text)
saved_error_text.set(session->StrError(res));
session->Close();
+ if(!verify_fn)
+ MakeVerifyFileName();
if(res==FA::NO_FILE)
{
/* If this is a CWD to the parent, and it failed, we
@@ -262,17 +280,7 @@ int GetFileInfo::Do()
/* Now that we've connected, we should have the home directory path. Find out
* the real name of the path. (We may have something like "~/..".) */
if(!verify_fn)
- {
- FileAccess::Path pwd(session->GetCwd());
-
- session->SetCwd(origdir);
- session->Chdir(dir, false);
-
- verify_fn.set(basename_ptr(session->GetCwd()));
-
- /* go back */
- session->SetCwd(pwd);
- }
+ MakeVerifyFileName();
/* Special case: looking up "/". Make a phony entry. */
if(showdir && !strcmp(verify_fn, "/"))
@@ -390,6 +398,10 @@ int GetFileInfo::Do()
* also serves as a last attempt to see if the file exists--we
* only get here if everything else thinks the path doesn't exist.
*/
+
+ /* verify_fn_mabe null. */
+ if(!verify_fn)
+ MakeVerifyFileName();
FileInfo *fi=new FileInfo(verify_fn);
fi->need=need;
/* We need to do at least one. */
diff --git a/src/GetFileInfo.h b/src/GetFileInfo.h
index 1ac8f4d..483dcc3 100644
--- a/src/GetFileInfo.h
+++ b/src/GetFileInfo.h
@@ -66,6 +66,8 @@ class GetFileInfo : public ListInfo
void PrepareToDie();
+ void MakeVerifyFileName();
+
public:
GetFileInfo(const FileAccessRef& a, const char *path, bool showdir);
virtual ~GetFileInfo();
--
2.23.0

View File

@ -1,7 +1,7 @@
Summary: A sophisticated file transfer program
Name: lftp
Version: 4.9.2
Release: 2
Release: 3
License: GPLv3+
URL: http://lftp.yar.ru/
Source0: http://lftp.yar.ru/ftp/%{name}-%{version}.tar.xz
@ -11,6 +11,8 @@ BuildRequires: chrpath
Patch0: lftp-4.0.9-date_fmt.patch
Patch1: Quit-while-source-file-increased.patch
Patch6000: backport-Ensure-that-PollVec-enum-matches-poll-values.patch
Patch6001: backport-fix-second-find_cmd-Segmentation-fault.patch
%description
LFTP is a sophisticated file transfer program supporting a number of
@ -84,6 +86,13 @@ echo "%{_libdir}/lftp/%{version}" > %{buildroot}/etc/ld.so.conf.d/%{name}-%{_arc
%changelog
* Thu Sep 8 2022 chengyechun <chengyechun1@huawei.com> - 4.9.2-3
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:fix second find_cmd Segmentation fault
Ensure that PollVec enum matches poll values
* Thu Oct 28 2021 zhouyihang <zhouyihang3@huawei.com> - 4.9.2-2
- Type:bugfix
- ID:NA