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

fix: prevent panic in nydus snapshotter inspect #3835

Merged
merged 1 commit into from
Jan 26, 2025

Conversation

SpiffyEight77
Copy link
Contributor

Description

image.Author = imgOCI.History[len(imgOCI.History)-1].Author
if !imgOCI.History[len(imgOCI.History)-1].Created.IsZero() {
image.Created = imgOCI.History[len(imgOCI.History)-1].Created.Format(time.RFC3339Nano)
image.Author = imgOCI.History[len(imgOCI.History)-1].Author
Copy link
Contributor

Choose a reason for hiding this comment

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

Does Author have to be inside the if test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does Author have to be inside the if test?

Oops, nice catch! The Author doesn't have to be inside the if test.🙇

Signed-off-by: Ruihua Wen <spiffyeight77@gmail.com>
@apostasie
Copy link
Contributor

LGTM

@fahedouch if you are around for a review ^

@@ -340,7 +340,9 @@ func ImageFromNative(nativeImage *native.Image) (*Image, error) {

if len(imgOCI.History) > 0 {
image.Comment = imgOCI.History[len(imgOCI.History)-1].Comment
image.Created = imgOCI.History[len(imgOCI.History)-1].Created.Format(time.RFC3339Nano)
if !imgOCI.History[len(imgOCI.History)-1].Created.IsZero() {
image.Created = imgOCI.History[len(imgOCI.History)-1].Created.Format(time.RFC3339Nano)
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to have len(imgOCI.History) = 0?
if yes we need an additional check to avoid slice out-of-range error

Copy link
Contributor

Choose a reason for hiding this comment

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

We are already testing for that: if len(imgOCI.History) > 0 {

Copy link
Member

Choose a reason for hiding this comment

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

cool. Sorry I was reviewing with my phone.

LGTM

@SpiffyEight77 SpiffyEight77 marked this pull request as ready for review January 26, 2025 05:10
@fahedouch fahedouch added this to the v2.x.x (tentative) milestone Jan 26, 2025
Copy link
Member

@fahedouch fahedouch left a comment

Choose a reason for hiding this comment

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

Thanks

@fahedouch fahedouch merged commit 1e8f43b into containerd:main Jan 26, 2025
30 checks passed
@SpiffyEight77 SpiffyEight77 deleted the fix/issue-3755 branch January 26, 2025 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nerdctl panic when run inspect --type=image xxxxx with nydus snapshotter
3 participants