Skip to content

fix: nil pointer dereference when os.OpenFile fails#12808

Open
mei2jun1 wants to merge 1 commit into
1Panel-dev:dev-v2from
mei2jun1:fix-nil-pointer-dereference-when-osopenfile-fails
Open

fix: nil pointer dereference when os.OpenFile fails#12808
mei2jun1 wants to merge 1 commit into
1Panel-dev:dev-v2from
mei2jun1:fix-nil-pointer-dereference-when-osopenfile-fails

Conversation

@mei2jun1
Copy link
Copy Markdown

@mei2jun1 mei2jun1 commented May 21, 2026

Summary

Fix nil pointer dereference when os.OpenFile fails in website_ssl.go Create()

Problem

On line 202-203 of agent/app/service/website_ssl.go, the error from os.OpenFile is silently discarded with _. If the call fails (e.g., the log directory doesn't exist or there are permission issues), logFile is nil, and the unconditional logFile.Close() on the very next line will panic with a nil pointer dereference.

Solution

Capture the error return value from os.OpenFile and guard the Close() call inside an else branch. When the open fails, log the error using the same pattern already used by newWebsiteSSLLogger() in the same file (global.LOG.Errorf). This keeps the change minimal and consistent with existing conventions.

Notes

The same file already handles this correctly in newWebsiteSSLLogger() (lines 229-233); this fix brings the Create() path in line with that established pattern.

@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot Bot commented May 21, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign zhengkunwang223 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant