44 lines
1.4 KiB
Diff
44 lines
1.4 KiB
Diff
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>
|
|
---
|
|
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
|
|
|