From: Timo Sirainen Date: Tue, 15 Nov 2016 16:39:08 +0000 (+0200) Subject: lib: Add connection.allow_empty_args_input X-Git-Tag: 2.2.27~108 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a14d0006121d12996838fccfb4db21929e4c2c20;p=thirdparty%2Fdovecot%2Fcore.git lib: Add connection.allow_empty_args_input This simplifies input_args() callbacks since they don't always have to check for args[0] == NULL. This is enabled by default, because none of the current users want it and it's somewhat unlikely there even will be those in future. --- diff --git a/src/lib/connection.c b/src/lib/connection.c index 0045149f67..844ffda70b 100644 --- a/src/lib/connection.c +++ b/src/lib/connection.c @@ -110,6 +110,10 @@ int connection_input_line_default(struct connection *conn, const char *line) conn->version_received = TRUE; return 1; } + if (args[0] == NULL && !conn->list->set.allow_empty_args_input) { + i_error("%s: Unexpectedly received empty line", conn->name); + return -1; + } return conn->list->v.input_args(conn, args); } diff --git a/src/lib/connection.h b/src/lib/connection.h index 84cc97c2ee..e768600392 100644 --- a/src/lib/connection.h +++ b/src/lib/connection.h @@ -58,6 +58,11 @@ struct connection_settings { bool client; bool dont_send_version; + /* By default when only input_args() is used, or when + connection_input_line_default() is used, empty lines aren't allowed + since it would result in additional args[0] == NULL check. Setting + this to TRUE passes it through instead of logging an error. */ + bool allow_empty_args_input; /* Don't call client_connected() immediately on connection_client_connect() with UNIX sockets. This is mainly to make the functionality identical with inet sockets, which may