]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap-zlib: Check that compression level is within supported range
authorAki Tuomi <aki.tuomi@open-xchange.com>
Tue, 30 Mar 2021 16:04:31 +0000 (19:04 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Tue, 13 Apr 2021 06:18:28 +0000 (09:18 +0300)
src/plugins/imap-zlib/imap-zlib-plugin.c

index 5ad423aa1a280be35a60f9fc2fb49acb330b7432..1035fbefb9195c34514a2840c788b6ab36edd870 100644 (file)
@@ -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;
 
        /* <mechanism> */
@@ -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);