From 8506d4c88579124bd8548061d02c03ab819e4a49 Mon Sep 17 00:00:00 2001 From: Zhang Jun Date: Mon, 17 Oct 2022 13:51:30 +0800 Subject: [PATCH] Prevent files from being skipped if the output buffer is too small --- libssh2.spec | 9 +++- ...les-from-being-skipped-if-the-output.patch | 43 +++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 sftp-Prevent-files-from-being-skipped-if-the-output.patch diff --git a/libssh2.spec b/libssh2.spec index f751b61..348690e 100644 --- a/libssh2.spec +++ b/libssh2.spec @@ -1,6 +1,6 @@ Name: libssh2 Version: 1.10.0 -Release: 3 +Release: 4 Summary: A library implementing the SSH2 protocol License: BSD URL: https://www.libssh2.org/ @@ -8,6 +8,7 @@ Source0: https://libssh2.org/download/libssh2-%{version}.tar.gz Patch0: backport-RSA-SHA2-256-512-key-upgrade-support-RFC-8332.patch Patch1: backport-misc-libssh2_copy_string-avoid-malloc-zero-bytes.patch +Patch2: sftp-Prevent-files-from-being-skipped-if-the-output.patch BuildRequires: coreutils findutils /usr/bin/man zlib-devel BuildRequires: gcc make sed openssl-devel > 1:1.0.1 openssh-server @@ -87,6 +88,12 @@ LC_ALL=en_US.UTF-8 make -C tests check %{_mandir}/man3/libssh2_*.3* %changelog +* Mon Oct 17 2022 zhangjun - 1.10.0-4 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:Prevent files from being skipped if the output buffer is too small + * Thu Sep 29 2022 zhangjun - 1.10.0-3 - Type:bugfix - ID:NA diff --git a/sftp-Prevent-files-from-being-skipped-if-the-output.patch b/sftp-Prevent-files-from-being-skipped-if-the-output.patch new file mode 100644 index 0000000..b8ce89c --- /dev/null +++ b/sftp-Prevent-files-from-being-skipped-if-the-output.patch @@ -0,0 +1,43 @@ +From bd9c65d68c4152ba0726f5588b4b611410972fbc Mon Sep 17 00:00:00 2001 +From: Gabriel Smith +Date: Fri, 23 Sep 2022 13:03:56 -0400 +Subject: [PATCH] sftp: Prevent files from being skipped if the output buffer + is too small (#746) + +Notes: +LIBSSH2_ERROR_BUFFER_TOO_SMALL is returned if the buffer is too small +to contain a returned directory entry. On this condition we jump to the +label `end`. At this point the number of names left is decremented +despite no name being returned. + +As suggested in #714, this commit moves the error label after the +decrement of `names_left`. + +Fixes #714 + +Credit: +Co-authored-by: Gabriel Smith +--- + src/sftp.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/sftp.c b/src/sftp.c +index b1a5352..2df918a 100644 +--- a/src/sftp.c ++++ b/src/sftp.c +@@ -1852,11 +1852,11 @@ static ssize_t sftp_readdir(LIBSSH2_SFTP_HANDLE *handle, char *buffer, + + handle->u.dir.next_name = (char *) s; + handle->u.dir.names_packet_len = names_packet_len; +- end: + + if((--handle->u.dir.names_left) == 0) + LIBSSH2_FREE(session, handle->u.dir.names_packet); + ++ end: + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, + "libssh2_sftp_readdir_ex() return %d", + filename_len); +-- +2.25.1 + -- Gitee