changeset 22227:fbeea0c7629f

imap-login: Fix crash in ID if trusted client sends NIL value to internal field 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))
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Wed, 14 Jun 2017 10:50:38 +0300
parents 56719ee6447a
children f2cb5e620543
files src/imap-login/imap-login-client.c
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap-login/imap-login-client.c	Tue Jun 13 22:14:11 2017 +0300
+++ b/src/imap-login/imap-login-client.c	Wed Jun 14 10:50:38 2017 +0300
@@ -161,9 +161,7 @@
 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 @@
 	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 {