From: Aki Tuomi Date: Tue, 29 Jul 2025 11:19:57 +0000 (+0300) Subject: master: Check that no other fd than DOVECOT_CONFIG_FD leaks X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b082674dc908eaa47f6072e299b3a95162c68dc2;p=thirdparty%2Fdovecot%2Fcore.git master: Check that no other fd than DOVECOT_CONFIG_FD leaks This fd is needed for configuration reading. --- diff --git a/src/master/main.c b/src/master/main.c index 554cc50f16..60d2a695b2 100644 --- a/src/master/main.c +++ b/src/master/main.c @@ -801,8 +801,19 @@ int main(int argc, char *argv[]) #ifdef DEBUG if (getenv("GDB") == NULL) { - fd_debug_verify_leaks(3, MASTER_CONFIG_FD - 1); - fd_debug_verify_leaks(MASTER_CONFIG_FD + 1, 1024); + const char *config_fd_env = getenv(DOVECOT_CONFIG_FD_ENV); + if (config_fd_env != NULL) { + int config_fd; + if (str_to_int(config_fd_env, &config_fd) < 0 || + config_fd <= 3 || config_fd >= 1024) { + i_fatal("'%s' is not valid number (in environment variable %s)", + config_fd_env, DOVECOT_CONFIG_FD_ENV); + } + fd_debug_verify_leaks(3, config_fd - 1); + fd_debug_verify_leaks(config_fd + 1, 1024); + } else { + fd_debug_verify_leaks(3, 1024); + } } #endif /* drop -- prefix from all --args. ugly, but the only way that it