From: Siavash Tavakoli Date: Thu, 19 Aug 2021 16:06:42 +0000 (+0100) Subject: dict-sql: Fail early if there's unexpected number of bind arguments for iter X-Git-Tag: 2.3.17~179 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=285cf9c84978af0d8380a80cc84b1655db8011cd;p=thirdparty%2Fdovecot%2Fcore.git dict-sql: Fail early if there's unexpected number of bind arguments for iter Otherwise, lib-sql raises a panic. --- diff --git a/src/lib-dict-backend/dict-sql.c b/src/lib-dict-backend/dict-sql.c index feb52e0b82..225da67833 100644 --- a/src/lib-dict-backend/dict-sql.c +++ b/src/lib-dict-backend/dict-sql.c @@ -368,6 +368,11 @@ sql_dict_where_build(const char *username, const struct dict_sql_map *map, str_append(query, " WHERE"); exact_count = count == count2 && recurse_type != SQL_DICT_RECURSE_NONE ? count2-1 : count2; + if (exact_count != array_count(values_arr)) { + *error_r = t_strdup_printf("Key continues past the matched pattern %s", map->pattern); + return -1; + } + for (i = 0; i < exact_count; i++) { if (i > 0) str_append(query, " AND");