From 919201405c9beeba9fffc142429521bb3050427b Mon Sep 17 00:00:00 2001 From: Stephan Bosch <stephan.bosch@dovecot.fi> Date: Sat, 3 Mar 2018 10:12:28 +0100 Subject: [PATCH] lib-sieve: Fix assert panic occurring when used command has external tag, but is not registered. This occurred for example when the "fileinto" command is used with only the "copy" extension in the require line. Panic message was: Panic: file hash.c: line 263 (hash_table_insert_node): assertion failed: (opcode == HASH_TABLE_OP_UPDATE) --- src/lib-sieve/sieve-validator.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib-sieve/sieve-validator.c b/src/lib-sieve/sieve-validator.c index 29b3a936b..846ac147e 100644 --- a/src/lib-sieve/sieve-validator.c +++ b/src/lib-sieve/sieve-validator.c @@ -352,8 +352,16 @@ void sieve_validator_register_command static void sieve_validator_register_unknown_command (struct sieve_validator *valdtr, const char *command) { - (void)_sieve_validator_register_command - (valdtr, NULL, &unknown_command, command); + struct sieve_command_registration *cmd_reg = + sieve_validator_find_command_registration(valdtr, command); + + if (cmd_reg == NULL) { + (void)_sieve_validator_register_command + (valdtr, NULL, &unknown_command, command); + } else { + i_assert(cmd_reg->cmd_def == NULL); + cmd_reg->cmd_def = &unknown_command; + } } /*const struct sieve_command *sieve_validator_find_command -- GitLab