From: Aki Tuomi Date: Tue, 30 Mar 2021 16:04:31 +0000 (+0300) Subject: imap-zlib: Check that compression level is within supported range X-Git-Tag: 2.3.15~110 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d4d2eec8a4d7c7690d166127c30bd755a2601a25;p=thirdparty%2Fdovecot%2Fcore.git imap-zlib: Check that compression level is within supported range --- diff --git a/src/plugins/imap-zlib/imap-zlib-plugin.c b/src/plugins/imap-zlib/imap-zlib-plugin.c index 5ad423aa1a..1035fbefb9 100644 --- a/src/plugins/imap-zlib/imap-zlib-plugin.c +++ b/src/plugins/imap-zlib/imap-zlib-plugin.c @@ -71,7 +71,7 @@ static bool cmd_compress(struct client_command_context *cmd) struct istream *old_input; struct ostream *old_output; const char *mechanism, *value; - unsigned int level; + int level; int ret; /* */ @@ -104,10 +104,13 @@ static bool cmd_compress(struct client_command_context *cmd) value = mail_user_plugin_getenv(client->user, "imap_zlib_compress_level"); - if (value == NULL || str_to_uint(value, &level) < 0 || - level <= 0 || level > 9) - level = IMAP_COMPRESS_DEFAULT_LEVEL; - + if (value == NULL || str_to_int(value, &level) < 0 || + level < handler->get_min_level() || level > handler->get_max_level()) { + i_error("imap_zlib_compress_level: Level must be between %d..%d", + handler->get_min_level(), + handler->get_max_level()); + level = handler->get_default_level(); + } old_input = client->input; old_output = client->output; client->input = handler->create_istream(old_input);