Skip to content

zoekt-indexserver: Prevent invalid config from causing an NPE#612

Merged
keegancsmith merged 1 commit into
sourcegraph:mainfrom
philwo:patch-1
Jul 12, 2023
Merged

zoekt-indexserver: Prevent invalid config from causing an NPE#612
keegancsmith merged 1 commit into
sourcegraph:mainfrom
philwo:patch-1

Conversation

@philwo

@philwo philwo commented Jul 12, 2023

Copy link
Copy Markdown
Contributor

When the user specifies an invalid mirror config that contains an entry without any of the GithubUser / GithubOrg / ... repository definitions, zoekt-indexserver would crash, because cmd stays nil and causes a SIGSEGV when it is later accessed in main.executeMirror:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x60 pc=0xb0ddba]
goroutine 10 [running]:
main.loggedRun(0x0)
        /home/philwo/go/pkg/mod/github.com/sourcegraph/zoekt@v0.0.0-20230711133754-25c1ea5177fb/cmd/zoekt-indexserver/main.go:45 +0x5a
main.executeMirror({0xc000d5a000?, 0x16?, 0x0?}, {0xc000246dc0, 0xc}, 0x0?)
        /home/philwo/go/pkg/mod/github.com/sourcegraph/zoekt@v0.0.0-20230711133754-25c1ea5177fb/cmd/zoekt-indexserver/config.go:265 +0x1dbd
main.periodicMirrorFile({0xc000246dc0, 0xc}, 0xc000283dc0, 0x0?)
        /home/philwo/go/pkg/mod/github.com/sourcegraph/zoekt@v0.0.0-20230711133754-25c1ea5177fb/cmd/zoekt-indexserver/config.go:150 +0x256
created by main.main
        /home/philwo/go/pkg/mod/github.com/sourcegraph/zoekt@v0.0.0-20230711133754-25c1ea5177fb/cmd/zoekt-indexserver/main.go:294 +0x685

Example config how to trigger this:

[
  {
    "CredentialPath": "/zoekt/etc/github-token"
  },
  ...
]

When the user specifies an invalid mirror config that contains an entry
without any of the GithubUser / GithubOrg / ... repository definitions,
zoekt-indexserver would crash, because `cmd` stays `nil` and causes a
SIGSEGV when it is later accessed in `main.executeMirror`:

```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x60 pc=0xb0ddba]
goroutine 10 [running]:
main.loggedRun(0x0)
        /home/philwo/go/pkg/mod/github.com/sourcegraph/zoekt@v0.0.0-20230711133754-25c1ea5177fb/cmd/zoekt-indexserver/main.go:45 +0x5a
main.executeMirror({0xc000d5a000?, 0x16?, 0x0?}, {0xc000246dc0, 0xc}, 0x0?)
        /home/philwo/go/pkg/mod/github.com/sourcegraph/zoekt@v0.0.0-20230711133754-25c1ea5177fb/cmd/zoekt-indexserver/config.go:265 +0x1dbd
main.periodicMirrorFile({0xc000246dc0, 0xc}, 0xc000283dc0, 0x0?)
        /home/philwo/go/pkg/mod/github.com/sourcegraph/zoekt@v0.0.0-20230711133754-25c1ea5177fb/cmd/zoekt-indexserver/config.go:150 +0x256
created by main.main
        /home/philwo/go/pkg/mod/github.com/sourcegraph/zoekt@v0.0.0-20230711133754-25c1ea5177fb/cmd/zoekt-indexserver/main.go:294 +0x685
```

Example config how to trigger this:

```
[
  {
    "CredentialPath": "/zoekt/etc/github-token"
  },
  ...
]
```
@keegancsmith

Copy link
Copy Markdown
Member

Thanks!

@keegancsmith keegancsmith merged commit 9abbb8b into sourcegraph:main Jul 12, 2023
@philwo philwo deleted the patch-1 branch July 12, 2023 07:19
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.

2 participants