]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Add connection.allow_empty_args_input
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 15 Nov 2016 16:39:08 +0000 (18:39 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 18 Nov 2016 11:55:49 +0000 (13:55 +0200)
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.

src/lib/connection.c
src/lib/connection.h

index 0045149f675705db3b5b5b9666b2d7d3252bd31f..844ffda70b17c4ef5b8e99f8fc52bad630afc528 100644 (file)
@@ -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);
 }
index 84cc97c2ee9a5cc40886dfee3e23703e7b8fef63..e76860039230836b3d39e3371fdf5a265c8b2d13 100644 (file)
@@ -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