codenotary / immudb

immudb - immutable database based on zero trust, SQL/Key-Value/Document model, tamperproof, data change history
https://immudb.io
Other
8.55k stars 343 forks source link

immuclient panic when using a wrongly formatted token #679

Closed ellisab closed 3 years ago

ellisab commented 3 years ago

What happened

alex@MacBook-Air immudb % ./immuclient panic: runtime error: makeslice: len out of range

goroutine 1 [running]: github.com/codenotary/immudb/pkg/client.(tokenService).parseContent(0x140000a8660, 0x140000a74b0, 0x140001ad928, 0x1, 0x0, 0x140000aa070, 0x140001ad901) /Users/alex/go/src/immudb/pkg/client/token_service.go:104 +0xb4 github.com/codenotary/immudb/pkg/client.(tokenService).GetToken(0x140000a8660, 0x1037a1260, 0x0, 0x0, 0x1) /Users/alex/go/src/immudb/pkg/client/token_service.go:46 +0x28 github.com/codenotary/immudb/pkg/client.(immuClient).SetupDialOptions(0x1400038a000, 0x1400008b800, 0x140000a8660) /Users/alex/go/src/immudb/pkg/client/client.go:308 +0x34c github.com/codenotary/immudb/pkg/client.NewImmuClient(0x1400008b800, 0x140001adc01, 0x0, 0x0, 0x140001add08) /Users/alex/go/src/immudb/pkg/client/client.go:199 +0x124 github.com/codenotary/immudb/cmd/immuclient/immuc.(immuc).Connect(0x140000be8c0, 0x1037a1260, 0x0, 0x0, 0x140001adcf0, 0x140001adcc8) /Users/alex/go/src/immudb/cmd/immuclient/immuc/init.go:91 +0x58 github.com/codenotary/immudb/cmd/immuclient/command.(commandline).NewCmd.func1(0x140000e2000, 0x1037a1260, 0x0, 0x0, 0x0, 0x0) /Users/alex/go/src/immudb/cmd/immuclient/command/root.go:49 +0x50 github.com/spf13/cobra.(Command).execute(0x140000e2000, 0x14000032210, 0x0, 0x0, 0x140000e2000, 0x14000032210) /Users/alex/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:842 +0x320 github.com/spf13/cobra.(Command).ExecuteC(0x140000e2000, 0x18, 0x20, 0x140000ec601) /Users/alex/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:950 +0x258 github.com/spf13/cobra.(Command).Execute(...) /Users/alex/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:887 github.com/codenotary/immudb/cmd/immuclient/command.Execute(0x140000e2000, 0x102a92ef4, 0x14000000180) /Users/alex/go/src/immudb/cmd/immuclient/command/cmd.go:32 +0x94 main.main() /Users/alex/go/src/immudb/cmd/immuclient/immuclient.go:30 +0x2c

What you expected to happen

No panic

How to reproduce it (as minimally and precisely as possible)

I have a randomly formatted token

alex@Alexandrus-Air ~ % cat token e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

Environment

alex@MacBook-Air immudb % ./immuclient version
immuclient 0.9.1
Commit  : c245f87014e0c7f30133f541fe3094d3f3c85b9f
Built by: boninialexandru@gmail.com
Built at: Fri, 02 Apr 2021 23:50:23 CEST

Additional info (any other context about the problem)

dmacvicar commented 3 years ago

Fixed in 84ecd0ba80c3dfc01233e378cdd1f4cff63d3f15