GUACAMOLE-818: Break SFTP directory JSON at blob boundaries. Do not skip entries.
The intent of the previous version of the SFTP directory listing code was to break the JSON transfer at blob boundaries, waiting for an ack before sending the next blob, however the ordering of the "blob_written" and directory read checks could result in a directory entry being skipped at the boundary of each blob. The proper order would be to check the "blob_written" flag first, however the "blob_written" flag is unnecessary. It's simpler and more correct to just break out of the loop once the desired blob has been flushed.
This commit is contained in:
parent
090bb3bbea
commit
8ea9b14a80
@ -586,7 +586,6 @@ static int guac_common_ssh_sftp_ls_ack_handler(guac_user* user,
|
|||||||
guac_stream* stream, char* message, guac_protocol_status status) {
|
guac_stream* stream, char* message, guac_protocol_status status) {
|
||||||
|
|
||||||
int bytes_read;
|
int bytes_read;
|
||||||
int blob_written = 0;
|
|
||||||
|
|
||||||
char filename[GUAC_COMMON_SSH_SFTP_MAX_PATH];
|
char filename[GUAC_COMMON_SSH_SFTP_MAX_PATH];
|
||||||
LIBSSH2_SFTP_ATTRIBUTES attributes;
|
LIBSSH2_SFTP_ATTRIBUTES attributes;
|
||||||
@ -608,8 +607,7 @@ static int guac_common_ssh_sftp_ls_ack_handler(guac_user* user,
|
|||||||
|
|
||||||
/* While directory entries remain */
|
/* While directory entries remain */
|
||||||
while ((bytes_read = libssh2_sftp_readdir(list_state->directory,
|
while ((bytes_read = libssh2_sftp_readdir(list_state->directory,
|
||||||
filename, sizeof(filename), &attributes)) > 0
|
filename, sizeof(filename), &attributes)) > 0) {
|
||||||
&& !blob_written) {
|
|
||||||
|
|
||||||
char absolute_path[GUAC_COMMON_SSH_SFTP_MAX_PATH];
|
char absolute_path[GUAC_COMMON_SSH_SFTP_MAX_PATH];
|
||||||
|
|
||||||
@ -639,9 +637,10 @@ static int guac_common_ssh_sftp_ls_ack_handler(guac_user* user,
|
|||||||
else
|
else
|
||||||
mimetype = "application/octet-stream";
|
mimetype = "application/octet-stream";
|
||||||
|
|
||||||
/* Write entry */
|
/* Write entry, waiting for next ack if a blob is written */
|
||||||
blob_written |= guac_common_json_write_property(user, stream,
|
if (guac_common_json_write_property(user, stream,
|
||||||
&list_state->json_state, absolute_path, mimetype);
|
&list_state->json_state, absolute_path, mimetype))
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user