From ddbbcf032aee552c7b4523d943bb1c1ec23f0581 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 5 Jul 2015 12:56:10 -0700 Subject: [PATCH] GUAC-1172: Ensure empty directories are valid JSON. --- src/protocols/ssh/sftp.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/protocols/ssh/sftp.c b/src/protocols/ssh/sftp.c index 55eeeefe..75b692a8 100644 --- a/src/protocols/ssh/sftp.c +++ b/src/protocols/ssh/sftp.c @@ -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);