]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap-login: Fix crash in ID if trusted client sends NIL value to internal field
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 14 Jun 2017 07:50:38 +0000 (10:50 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Fri, 16 Jun 2017 06:36:35 +0000 (09:36 +0300)
Fixes:
Panic: imap-login: file imap-login-client.c: line 215 (cmd_id_handle_keyvalue): assertion failed: (client_id_str == !client_id_reserved_word(key))

src/imap-login/imap-login-client.c

index a31d7d45fce7ae3c8dc9f4986c91a24719faccb5..a4b1957665f80ccf98491c34dfeba467a3534748 100644 (file)
@@ -161,9 +161,7 @@ static bool
 client_update_info(struct imap_client *client,
                   const char *key, const char *value)
 {
-       /* do not try to process NIL value */
-       if (value == NULL)
-               return FALSE;
+       i_assert(value != NULL);
 
        /* SYNC WITH imap_login_reserved_id_keys */
 
@@ -210,7 +208,10 @@ static void cmd_id_handle_keyvalue(struct imap_client *client,
        size_t kvlen = strlen(key) + 2 + 1 +
                       (value == NULL ? 3 : strlen(value)) + 2;
 
-       if (client->common.trusted && !client->id_logged) {
+       if (value == NULL) {
+               /* do not try to process NIL value */
+               client_id_str = FALSE;
+       } else if (client->common.trusted && !client->id_logged) {
                client_id_str = !client_update_info(client, key, value);
                i_assert(client_id_str == !client_id_reserved_word(key));
        } else {