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

Fix crash when KV store has a zero-length key. #9881

Merged
merged 3 commits into from
Sep 2, 2020
Merged

Conversation

mgritter
Copy link
Contributor

@mgritter mgritter commented Sep 2, 2020

Unit test successfully demonstrates the crash:

--- FAIL: TestCoreMetrics_KvSecretGauge_BadPath (0.03s)
panic: runtime error: index out of range [-1] [recovered]
	panic: runtime error: index out of range [-1]

goroutine 9 [running]:
testing.tRunner.func1.1(0x2e2d400, 0xc0007a8680)
	/usr/local/go/src/testing/testing.go:1057 +0x30d
testing.tRunner.func1(0xc000643e00)
	/usr/local/go/src/testing/testing.go:1060 +0x41a
panic(0x2e2d400, 0xc0007a8680)
	/usr/local/go/src/runtime/panic.go:969 +0x175
github.com/hashicorp/vault/vault.(*Core).walkKvMountSecrets(0xc0001de600, 0x35b39e0, 0xc000703a10, 0xc0007039e0)
	/home/mgritter/vault/vault/core_metrics.go:297 +0xa94
github.com/hashicorp/vault/vault.(*Core).kvSecretGaugeCollector(0xc0001de600, 0x35b39e0, 0xc000703a10, 0xc0007038f0, 0x0, 0x0, 0x5, 0xc000798840)
	/home/mgritter/vault/vault/core_metrics.go:332 +0xd3
github.com/hashicorp/vault/vault.TestCoreMetrics_KvSecretGauge_BadPath(0xc000643e00)
	/home/mgritter/vault/vault/core_metrics_test.go:175 +0x478
testing.tRunner(0xc000643e00, 0x3190700)
	/usr/local/go/src/testing/testing.go:1108 +0xef
created by testing.(*T).Run
	/usr/local/go/src/testing/testing.go:1159 +0x386

@mgritter mgritter merged commit d671cb2 into master Sep 2, 2020
@briankassouf briankassouf deleted the fix_bug_vault_520 branch September 3, 2020 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants