-
Notifications
You must be signed in to change notification settings - Fork 638
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
Conversation
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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>
2bd7c9a
to
6e5e943
Compare
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 {
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
Description