Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ShellPkg: Fix copy-pasto in NULL check to prevent segfault #5968

Merged
merged 1 commit into from
Nov 24, 2024

Conversation

tormodvolden
Copy link
Contributor

@tormodvolden tormodvolden commented Jul 25, 2024

Description

The UpdateArgcArgv() function documentation says "If OldArgv or OldArgc is NULL then that value is not returned."

However, only OldArgc was checked for NULL. In case OldArgc was non-NULL, but OldArgv was NULL, it could cause a segmentation fault.

  • Breaking change?
    • Breaking change - Does this PR cause a break in build or boot behavior?
    • Examples: Does it add a new library class or move a module to a different repo.
  • Impacts security?
    • Security - Does this PR have a direct security impact?
    • Examples: Crypto algorithm change or buffer overflow fix.
  • Includes tests?
    • Tests - Does this PR include any explicit test code?
    • Examples: Unit tests or integration tests.

How This Was Tested

Not tested. Not sure if any of the current code calls UpdateArgcArgv() with OldArgc non-NULL and OldArgv NULL.

Integration Instructions

N/A

@tormodvolden tormodvolden marked this pull request as ready for review July 25, 2024 12:52
Copy link

This PR has been automatically marked as stale because it has not had activity in 60 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions.

@github-actions github-actions bot added the stale Due to lack of updates, this item is pending deletion. label Sep 23, 2024
@tormodvolden
Copy link
Contributor Author

keep-alive

@mdkinney
Copy link
Member

Close and re-open to get reviewers assigned

@tormodvolden
Copy link
Contributor Author

tormodvolden commented Sep 24, 2024

Thanks! I tried to close and reopen some other PRs of mine, but no reviewers were added.

EDIT: I see now they were not added immediately here either, so I may just have to be patient. EDIT 2: Indeed.

Copy link
Contributor

@pierregondois pierregondois left a comment

Choose a reason for hiding this comment

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

The code change itself looks ok, maybe just to be a bit more concise in the commit message:

ShellPkg: Fix check on OldArgv in UpdateArgcArgv()

Check OldArgv is not NULL before dereferencing the value.

@pierregondois pierregondois removed the stale Due to lack of updates, this item is pending deletion. label Sep 24, 2024
@tormodvolden
Copy link
Contributor Author

@pierregondois Thanks for the suggestion. I rebased to current master and amended the commit message. I think it is still worth mentioning that the bug could cause a segmentation fault.

@pierregondois
Copy link
Contributor

@tormodvolden Thanks for updating the commit message. I think you could still remove this part:

However, only OldArgc was checked for NULL, probably because of
copy-pasto. In case OldArgc was non-NULL, but OldArgv was null, it could
cause a segmentation fault.

or in general, be less verbose and more factual:

  • copy-pasto is more slang
  • I don't think that much detail is required for the patch, the change is self-explanatory
  • No need to write the commit message at the past (cf. was ...)

The UpdateArgcArgv() function documentation says "If OldArgv or OldArgc
is NULL then that value is not returned."

However, only OldArgc was checked for NULL, probably because of
copy-pasto. In case OldArgc was non-NULL, but OldArgv was null, it could
cause a segmentation fault.

Check OldArgv is not NULL before dereferencing the value.

Signed-off-by: Tormod Volden <[email protected]>
@tormodvolden
Copy link
Contributor Author

I rebased to latest master.

@mdkinney mdkinney added the push Auto push patch series in PR if all checks pass label Nov 24, 2024
@mergify mergify bot merged commit 8002056 into tianocore:master Nov 24, 2024
126 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
push Auto push patch series in PR if all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants