]> 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)
committerGitLab <gitlab@git.dovecot.net>
Wed, 14 Jun 2017 14:08:04 +0000 (17:08 +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 d6a3098e2962a9d92157cb37690917a6171efea5..317113bfb43832e08a17495b1d927a8700e9cff2 100644 (file)
@@ -175,9 +175,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 */
 
@@ -224,7 +222,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 {