]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
maildir: Add assert to make sure dirfd() returns a valid fd
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 14 Oct 2025 09:49:34 +0000 (12:49 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Tue, 14 Oct 2025 15:27:29 +0000 (15:27 +0000)
src/lib-storage/index/maildir/maildir-sync.c

index 2321f2105c7e01648e3a07dfc53f4a2f7663e078..5f18fd4ab7caadec689ab67dcf9b4b8882d9c13f 100644 (file)
@@ -438,7 +438,9 @@ maildir_scan_dir(struct maildir_sync_context *ctx, bool new_dir, bool final,
        }
 
 #ifdef HAVE_DIRFD
-       if (fstat(dirfd(dirp), &st) < 0) {
+       int fd = dirfd(dirp);
+       i_assert(fd != -1);
+       if (fstat(fd, &st) < 0) {
                mailbox_set_critical(&ctx->mbox->box,
                        "fstat(%s) failed: %m", path);
                (void)closedir(dirp);