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

Possible nil-deref in image-automation controller #246

Closed
dholbach opened this issue Oct 27, 2021 · 4 comments · Fixed by #283
Closed

Possible nil-deref in image-automation controller #246

dholbach opened this issue Oct 27, 2021 · 4 comments · Fixed by #283
Assignees
Labels
good first issue Good for newcomers

Comments

@dholbach
Copy link

From Ada Logics:

Consider the following code:

if rev, err := commitChangedManifests(tracelog, repo, tmp, signingEntity, author, message); err != nil {
if err == errNoChanges {
r.event(ctx, auto, events.EventSeverityInfo, "no updates made")
debuglog.Info("no changes made in working directory; no commit")
statusMessage = "no updates made"
if lastCommit, lastTime := auto.Status.LastPushCommit, auto.Status.LastPushTime; lastCommit != "" {
statusMessage = fmt.Sprintf("%s; last commit %s at %s", statusMessage, lastCommit[:7], lastTime.Format(time.RFC3339))
}
} else {
return failWithError(err)
}

When the lastTime.Format is called it is not certain that lastTime is not a nil-pointer. As such, similar to a check on lastCommit there should be a check on whether lastTime is nil.

@relu relu added the good first issue Good for newcomers label Nov 11, 2021
@Nalum
Copy link
Member

Nalum commented Dec 17, 2021

I'd like to take up this issue if that's good with you

@Nalum
Copy link
Member

Nalum commented Dec 17, 2021

At the moment there is no error message returned if lastCommit is an empty string, is this okay to stay this way or should there be an else failWithError at this point?

I guess the statusMessage would still be no updates made which is still relevant in that case?

@Nalum
Copy link
Member

Nalum commented Dec 17, 2021

If lastCommit is not an empty string but lastTime is nil do you still want lastCommit in statusMessage?

I feel like it's unlikely to happen that you would have one without the other but it is possible.

@hiddeco
Copy link
Member

hiddeco commented Dec 17, 2021

I feel the presence of both is required for the observation to be correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants