From f813057d5060171ea345511ee02d8670eb05637e Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Tue, 13 May 2014 23:33:52 +0200 Subject: [PATCH] frontend: Treat CONNECTION_IDLE as an invalid command. This is only meant for internal use; don't silently ignore it. --- src/frontend/connection.c | 4 ++++ t/unit/frontend/connection_test.c | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/frontend/connection.c b/src/frontend/connection.c index a146e29..923f000 100644 --- a/src/frontend/connection.c +++ b/src/frontend/connection.c @@ -376,6 +376,10 @@ command_init(sdb_conn_t *conn) len = 2 * sizeof(uint32_t); if (conn->cmd == CONNECTION_IDLE) { + const char *errmsg = "Invalid command 0"; + sdb_strbuf_sprintf(conn->errbuf, errmsg); + sdb_connection_send(conn, CONNECTION_ERROR, + (uint32_t)strlen(errmsg), errmsg); len += conn->cmd_len; conn->cmd_len = 0; } diff --git a/t/unit/frontend/connection_test.c b/t/unit/frontend/connection_test.c index 125bb56..da94f06 100644 --- a/t/unit/frontend/connection_test.c +++ b/t/unit/frontend/connection_test.c @@ -210,13 +210,13 @@ START_TEST(test_conn_setup) const char *err; } golden_data[] = { { UINT32_MAX, NULL, NULL }, - { CONNECTION_IDLE, "fakedata", NULL }, + { CONNECTION_IDLE, "fakedata", "Invalid command 0" }, { CONNECTION_PING, NULL, "Authentication required" }, { CONNECTION_STARTUP, "fakeuser", NULL }, { CONNECTION_PING, NULL, NULL }, - { CONNECTION_IDLE, NULL, NULL }, + { CONNECTION_IDLE, NULL, "Invalid command 0" }, { CONNECTION_PING, "fakedata", NULL }, - { CONNECTION_IDLE, NULL, NULL }, + { CONNECTION_IDLE, NULL, "Invalid command 0" }, }; size_t i; -- 2.30.2