]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
master: Check that no other fd than DOVECOT_CONFIG_FD leaks
authorAki Tuomi <aki.tuomi@open-xchange.com>
Tue, 29 Jul 2025 11:19:57 +0000 (14:19 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 30 Jul 2025 06:31:44 +0000 (09:31 +0300)
This fd is needed for configuration reading.

src/master/main.c

index 554cc50f167842e269d201c98e82fc6bc4b06e1d..60d2a695b2abfc7c5cc7b1c1faa726a5a11e641e 100644 (file)
@@ -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