GUACAMOLE-222: Ensure files downloaded via SFTP are explicitly closed upon completion.
This commit is contained in:
parent
077cc84d27
commit
58b85da8f2
@ -373,18 +373,29 @@ static int guac_common_ssh_sftp_ack_handler(guac_user* user,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If EOF, send end */
|
/* If bytes could not be read, handle EOF or error condition */
|
||||||
else if (bytes_read == 0) {
|
|
||||||
guac_user_log(user, GUAC_LOG_DEBUG, "File sent");
|
|
||||||
guac_protocol_send_end(user->socket, stream);
|
|
||||||
guac_user_free_stream(user, stream);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Otherwise, fail stream */
|
|
||||||
else {
|
else {
|
||||||
guac_user_log(user, GUAC_LOG_INFO, "Error reading file");
|
|
||||||
guac_protocol_send_end(user->socket, stream);
|
/* If EOF, send end */
|
||||||
guac_user_free_stream(user, stream);
|
if (bytes_read == 0) {
|
||||||
|
guac_user_log(user, GUAC_LOG_DEBUG, "File sent");
|
||||||
|
guac_protocol_send_end(user->socket, stream);
|
||||||
|
guac_user_free_stream(user, stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Otherwise, fail stream */
|
||||||
|
else {
|
||||||
|
guac_user_log(user, GUAC_LOG_INFO, "Error reading file");
|
||||||
|
guac_protocol_send_end(user->socket, stream);
|
||||||
|
guac_user_free_stream(user, stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close file */
|
||||||
|
if (libssh2_sftp_close(file) == 0)
|
||||||
|
guac_user_log(user, GUAC_LOG_DEBUG, "File closed");
|
||||||
|
else
|
||||||
|
guac_user_log(user, GUAC_LOG_INFO, "Unable to close file");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
guac_socket_flush(user->socket);
|
guac_socket_flush(user->socket);
|
||||||
|
Loading…
Reference in New Issue
Block a user