From e45df3626af75014e47791c3412a2aee9cfe3013 Mon Sep 17 00:00:00 2001 From: Stephan Bosch 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 3319572b5..90051d0bb 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