GUAC-1172: Ensure empty directories are valid JSON.

This commit is contained in:
Michael Jumper 2015-07-05 12:56:10 -07:00
parent a6e9e0cfca
commit ddbbcf032a

View File

@ -624,6 +624,11 @@ int guac_sftp_ls_ack_handler(guac_client* client, guac_stream* stream,
/* Complete JSON and cleanup at end of directory */
if (bytes_read <= 0) {
/* Ensure leading brace is written */
if (list_state->entries_written == 0)
blob_written |= guac_sftp_ls_write_json(client, stream,
list_state, "{", 1);
/* Write end of JSON */
guac_sftp_ls_write_json(client, stream, list_state, "}", 1);
guac_sftp_ls_flush_json(client, stream, list_state);