Skip to content

fix: 无参数启动时可能把空指针传给 execvp#1704

Open
enkilee wants to merge 3 commits into
OpenAtom-Linyaps:masterfrom
enkilee:fix-llinit-error
Open

fix: 无参数启动时可能把空指针传给 execvp#1704
enkilee wants to merge 3 commits into
OpenAtom-Linyaps:masterfrom
enkilee:fix-llinit-error

Conversation

@enkilee

@enkilee enkilee commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

问题根因: parse_args() 在末尾无条件 emplace_back(nullptr),导致:
argc=1(无子命令)时,args = {nullptr},args.empty() 为 false,空参检查永远不生效
args[0] 是 nullptr,传入 execvp(nullptr, ...) 是未定义行为

修复内容(2处改动):
parse_args() (ll-init.cpp:238) — 移除末尾的 args.emplace_back(nullptr)。现在 parse_args 只返回实际的参数指针,args.empty() 能正确检测无参数的情况。
run() (ll-init.cpp:261) — 将参数类型改为 const std::vector<const char *> &(避免不必要的拷贝),并在 fork 后的子进程中构造局部的以 null 结尾的 c_args 数组传给 execvp。这与 delegate_run() 函数(第459行)的模式一致。

修复后的行为:
argc=1 → args 为空 → args.empty() 为 true → 打印 "No arguments provided" 并返回 -1
argc>1 → args 包含实际参数 → run() 中构造 null-terminated 数组 → execvp 正常执行

@deepin-ci-robot

Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: enkilee

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

@deepin-ci-robot

Copy link
Copy Markdown
Collaborator

Hi @enkilee. Thanks for your PR.

I'm waiting for a OpenAtom-Linyaps member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors argument parsing and execution in ll-init.cpp by passing arguments to run by reference and constructing a null-terminated array for execvp inside the child process. The review feedback recommends preparing this null-terminated array in the parent process before calling fork() to avoid unsafe heap allocations in the child process, ensuring compliance with async-signal-safe standards.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread apps/ll-init/src/ll-init.cpp
Comment thread apps/ll-init/src/ll-init.cpp Outdated
@reddevillg

Copy link
Copy Markdown
Collaborator

可以 squash 成一个 commit 吗?

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.

3 participants