Mercurial > dovecot > core-2.2
changeset 21160:66fad2161837
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.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Tue, 15 Nov 2016 18:39:08 +0200 |
parents | 569c9a928b26 |
children | 41e263e7f42c |
files | src/lib/connection.c src/lib/connection.h |
diffstat | 2 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib/connection.c Thu Nov 17 15:59:02 2016 -0500 +++ b/src/lib/connection.c Tue Nov 15 18:39:08 2016 +0200 @@ -110,6 +110,10 @@ 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); }
--- a/src/lib/connection.h Thu Nov 17 15:59:02 2016 -0500 +++ b/src/lib/connection.h Tue Nov 15 18:39:08 2016 +0200 @@ -58,6 +58,11 @@ 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