Fix 718: How to handle filenames with newline characters by remote commands
authorColin Clark <cclark@carbon>
Fri, 8 Nov 2019 13:36:47 +0000 (13:36 +0000)
committerColin Clark <cclark@carbon>
Fri, 8 Nov 2019 13:36:47 +0000 (13:36 +0000)
The fix uses a character string to identify the end-of-command.
A correct implementation would use the null character instead of a
string.

src/remote.c

index 73b8ae7..2c3e503 100644 (file)
@@ -121,7 +121,8 @@ static gboolean remote_server_client_cb(GIOChannel *source, GIOCondition conditi
                gchar *buffer = NULL;
                GError *error = NULL;
                gsize termpos;
-
+               /* FIXME: it should be possible to terminate the command with a null character */
+               g_io_channel_set_line_term(source, "<gq_end_of_command>\n", -1);
                while ((status = g_io_channel_read_line(source, &buffer, NULL, &termpos, &error)) == G_IO_STATUS_NORMAL)
                        {
                        if (buffer)
@@ -347,7 +348,7 @@ static gboolean remote_client_send(RemoteConnection *rc, const gchar *text)
        channel = g_io_channel_unix_new(rc->fd);
 
        g_io_channel_write_chars(channel, text, -1, NULL, &error);
-       g_io_channel_write_chars(channel, "\n", -1, NULL, &error);
+       g_io_channel_write_chars(channel, "<gq_end_of_command>\n", -1, NULL, &error);
        g_io_channel_flush(channel, &error);
 
        if (error)