Skip to content

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

Merged
wanghe-fit2cloud merged 1 commit into
1Panel-dev:dev-v2from
mei2jun1:fix-nil-pointer-dereference-when-osopenfile-fails
May 25, 2026
Merged

fix: nil pointer dereference when os.OpenFile fails#12808
wanghe-fit2cloud merged 1 commit into
1Panel-dev:dev-v2from
mei2jun1:fix-nil-pointer-dereference-when-osopenfile-fails

Conversation

@mei2jun1
Copy link
Copy Markdown
Contributor

@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

@wanghe-fit2cloud wanghe-fit2cloud merged commit 4443ed1 into 1Panel-dev:dev-v2 May 25, 2026
1 check was pending
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.

2 participants