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

cmd/zlint: fix panic w/ deref of nil registry. #385

Merged
merged 1 commit into from
Feb 11, 2020

Conversation

cpu
Copy link
Member

@cpu cpu commented Feb 11, 2020

This fixes a panic that can occur when there are no filtering arguments provided to the zlint command line tool introduced in 7741587.

This occurs because setLints returned a nil Registry when the intention was to use the global registry:

zlint/cmd/zlint/main.go

Lines 181 to 184 in 7741587

// If there's no filter options set, use the global registry as-is
if nameFilter == "" && includeNames == "" && excludeNames == "" && includeSources == "" && excludeSources == "" {
return nil, nil
}

Before fix:

$ zlint -list-lints-source
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x38 pc=0x717bd0]

goroutine 1 [running]:
main.main()
	/home/daniel/go/src/github.com/zmap/zlint/cmd/zlint/main.go:85 +0xe0

After fix:

$ zlint -list-lints-source
    AWSLabs
    Apple
    CABF_BR
    CABF_EV
    ETSI_ESI
    Mozilla
    RFC5280
    RFC5480
    RFC5891
    ZLint

This fixes a panic that can occur when there are no filtering arguments
provided to the `zlint` command line tool.

This occurs because `setLints` returned a `nil` `Registry` when the intention
was to use the global registry.

Before fix:
```
$ zlint -list-lints-source
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x38 pc=0x717bd0]

goroutine 1 [running]:
main.main()
	/home/daniel/go/src/github.com/zmap/zlint/cmd/zlint/main.go:85 +0xe0
```

After fix:
```
$ zlint -list-lints-source
    AWSLabs
    Apple
    CABF_BR
    CABF_EV
    ETSI_ESI
    Mozilla
    RFC5280
    RFC5480
    RFC5891
    ZLint
```
@cpu cpu self-assigned this Feb 11, 2020
@cpu cpu requested a review from dadrian February 11, 2020 19:55
@cpu
Copy link
Member Author

cpu commented Feb 11, 2020

Sorry I missed this one 😓

@cpu cpu merged commit 79424f2 into zmap:master Feb 11, 2020
@cpu cpu deleted the cpu-fix-zlint-cmd-null-deref branch February 11, 2020 20:10
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.

None yet

2 participants