Skip to content

Conversation

@grey3228
Copy link

Hello!

I used SAST tool Svace to analyze source code and encountered possible nil deref.

In function rm variable report might be initialized as nil as a result of call
registry.ImageEngine().Remove(registry.Context(), args, imageOpts). Then, there is a call registry.SetExitCode(report.ExitCode) without explicit nil check before. Check len(rmErrors) > 0 doesn't guarantee that report is a non-nil value.
So such call may lead to nil deref.

This PR adds check report for nil before its dereference.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Checklist

Ensure you have completed the following checklist for your pull request to be reviewed:

  • Certify you wrote the patch or otherwise have the right to pass it on as an open-source patch by signing all
    commits. (git commit -s). (If needed, use git commit -s --amend). The author email must match
    the sign-off email address. See CONTRIBUTING.md
    for more information.
  • Referenced issues using Fixes: #00000 in commit message (if applicable)
  • Tests have been added/updated (or no tests are needed)
  • Documentation has been updated (or no documentation changes are needed)
  • All commits pass make validatepr (format/lint checks)
  • Release note entered in the section below (or None if no user-facing changes)

Does this PR introduce a user-facing change?

None

In function rm variable `report` might be initialized as nil as a result
of call
`registry.ImageEngine().Remove(registry.Context(), args, imageOpts)`.
Then, there is a call `registry.SetExitCode(report.ExitCode)` without
explicit nil check before. Check `len(rmErrors) > 0` doesn't guarantee
that report is a non-nil value.
So such call may lead to nil deref.

This commit adds check `report` for nil before its dereference.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Mikhail Dmitrichenko <m.dmitrichenko222@gmail.com>
@baude baude added the No New Tests Allow PR to proceed without adding regression tests label Nov 20, 2025
@baude
Copy link
Member

baude commented Nov 20, 2025

LGTM

@mheon
Copy link
Member

mheon commented Nov 20, 2025

Sure
/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 20, 2025
@mheon
Copy link
Member

mheon commented Nov 20, 2025

/approve

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 20, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: grey3228, mheon

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

The pull request process is described here

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 20, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit 516feff into containers:main Nov 20, 2025
79 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. No New Tests Allow PR to proceed without adding regression tests release-note-none

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants