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

Add nil check of spec.Process in validateProcessSpec() #2413

Merged
merged 2 commits into from
May 18, 2020

Conversation

JFHwang
Copy link
Contributor

@JFHwang JFHwang commented May 16, 2020

Signed-off-by: John Hwang [email protected]

Short 3 line nil check to ensure spec.Process exists before validating its contents.

Closes #2392

@kolyshkin kolyshkin changed the title Add nil check of spec.Process in validateProcessSpec(). Closes #2392 Add nil check of spec.Process in validateProcessSpec() May 16, 2020
@kolyshkin
Copy link
Contributor

kolyshkin commented May 16, 2020

@JFHwang thank you for your contribution! I have modified the PR subject and description a bit.

Can you please change the commit description to say not what it's doing (as it's very clear from the patch itself) but why are you doing it, or what is the resulting effect? Something like "validateProcessSpec: prevent SEGV with invalid config".

utils_linux.go Outdated
@@ -378,6 +378,9 @@ func (r *runner) checkTerminal(config *specs.Process) error {
}

func validateProcessSpec(spec *specs.Process) error {
if spec == nil {
return fmt.Errorf("process property must not be empty")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: since there's no formatting, it's better to use errrors.New().

You can add a patch just before this one, converting the other places like this.

Copy link
Contributor Author

@JFHwang JFHwang May 16, 2020

Choose a reason for hiding this comment

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

Okay, will do. Thanks for the advice!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, I'm a bit unsure what is meant by a patch. Does this relate to git's patch files? A separate issue? A separate commit? Or just another change I apply to the current commit?
Thanks!

Copy link
Contributor

@kolyshkin kolyshkin May 16, 2020

Choose a reason for hiding this comment

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

I mean two separate commits in this same PR. First one doing cleanup replacing fmt.Errorf() to errors.New() in this file in cases there are no %-style formatting. Second is what you did.

@JFHwang JFHwang force-pushed the 2392-spec-check branch 3 times, most recently from e021f83 to d20605d Compare May 17, 2020 00:30
@JFHwang JFHwang force-pushed the 2392-spec-check branch from d20605d to 186e89d Compare May 17, 2020 01:18
@AkihiroSuda
Copy link
Member

AkihiroSuda commented May 17, 2020

LGTM

Approved with PullApprove

@kolyshkin
Copy link
Contributor

@JFHwang you forgot to use errors.New() in the second commit

otherwise LGTM

@JFHwang JFHwang force-pushed the 2392-spec-check branch from 186e89d to 5aa0601 Compare May 18, 2020 16:40
@kolyshkin
Copy link
Contributor

kolyshkin commented May 18, 2020

LGTM

Approved with PullApprove

1 similar comment
@AkihiroSuda
Copy link
Member

AkihiroSuda commented May 18, 2020

LGTM

Approved with PullApprove

@AkihiroSuda AkihiroSuda merged commit f369199 into opencontainers:master May 18, 2020
AkihiroSuda added a commit to AkihiroSuda/runc that referenced this pull request May 19, 2020
The compilation error had ocurred because of a bad rebase during opencontainers#2401 and opencontainers#2413

Signed-off-by: Akihiro Suda <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SIGSEV when parsing invalid configuration
3 participants