Skip to content

logging: close file handle on permission errors when not rolling (#7833)#7838

Open
vvdvortsova wants to merge 1 commit into
caddyserver:masterfrom
vvdvortsova:fix-7833-3-add-close
Open

logging: close file handle on permission errors when not rolling (#7833)#7838
vvdvortsova wants to merge 1 commit into
caddyserver:masterfrom
vvdvortsova:fix-7833-3-add-close

Conversation

@vvdvortsova

Copy link
Copy Markdown

I'm not a native English speaker, so I used AI to help translate this PR description. The code and analysis are my own.

Fix resource leak in OpenWriter.
Fix for issue #7833.

What

In FileWriter.OpenWriter (modules/logging/filewriter.go), when roll: false and a custom mode is configured, the function could return early (on a Stat or Chmod error) without ever closing the previously opened file, leaking the descriptor. Added file.Close() on both error-return paths inside that block. The success path (returning the open file handle to the caller when !roll) is left untouched, since that handle is intentionally returned open to the caller.

Testing
go build ./modules/logging/...
go vet ./modules/logging/...

@CLAassistant

CLAassistant commented Jun 23, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants