!31 回合社区补丁:sftp: Prevent files from being skipped if the output buffer is too small

From: @renmingshuai 
Reviewed-by: @seuzw 
Signed-off-by: @seuzw
This commit is contained in:
openeuler-ci-bot 2022-10-19 02:07:25 +00:00 committed by Gitee
commit bb8a0d8017
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 53 additions and 1 deletions

View File

@ -0,0 +1,45 @@
From bd9c65d68c4152ba0726f5588b4b611410972fbc Mon Sep 17 00:00:00 2001
From: Gabriel Smith <ga29smith@gmail.com>
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 <gabriel.smith@precisionot.com>
Conflict:NA
Reference:https://github.com/libssh2/libssh2/commit/bd9c65d68c
---
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

View File

@ -1,12 +1,13 @@
Name: libssh2
Version: 1.10.0
Release: 2
Release: 3
Summary: A library implementing the SSH2 protocol
License: BSD
URL: https://www.libssh2.org/
Source0: https://libssh2.org/download/libssh2-%{version}.tar.gz
Patch0: backport-RSA-SHA2-256-512-key-upgrade-support-RFC-8332.patch
Patch1: backport-sftp-Prevent-files-from-being-skipped-if-the.patch
BuildRequires: coreutils findutils /usr/bin/man zlib-devel
BuildRequires: gcc make sed openssl-devel > 1:1.0.1 openssh-server
@ -86,6 +87,12 @@ LC_ALL=en_US.UTF-8 make -C tests check
%{_mandir}/man3/libssh2_*.3*
%changelog
* Wed Oct 19 2022 renmingshuai <renmingshuai@huawei.com> - 1.10.0-3
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:sftp:Prevent files from being skipped
* Fri Jan 07 2022 xingwei <xingwei14@huawei.com> - 1.10.0-2
- Type:bugfix
- ID:NA