From: Sebastian Harl Date: Tue, 13 May 2014 21:33:52 +0000 (+0200) Subject: frontend: Treat CONNECTION_IDLE as an invalid command. X-Git-Tag: sysdb-0.1.0~25 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f813057d5060171ea345511ee02d8670eb05637e;p=sysdb.git frontend: Treat CONNECTION_IDLE as an invalid command. This is only meant for internal use; don't silently ignore it. --- 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;