cli
cli copied to clipboard
CLI segfaults if it receives a malformed error.
trafficstars
The CLI assumes in lots of places that errors will contain a payload with a well formed error message:
"error":{
"message": "something"
}
}```
If the response is not formed correctly the CLI will segfault, eg:
```panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x158a665]
goroutine 1 [running]:
main.(*appsCmd).create(0xc4200b00c8, 0xc4200fa6e0, 0x0, 0x1)
/Users/rconnon/go/src/github.com/fnproject/cli/apps.go:185 +0x245
main.(*appsCmd).(main.create)-fm(0xc4200fa6e0, 0x0, 0x0)
/Users/rconnon/go/src/github.com/fnproject/cli/apps.go:40 +0x34
github.com/fnproject/cli/vendor/github.com/urfave/cli.HandleAction(0x162dbe0, 0xc42043f150, 0xc4200fa6e0, 0x1, 0x0)
/Users/rconnon/go/src/github.com/fnproject/cli/vendor/github.com/urfave/cli/app.go:490 +0xc8
main.prepareCmdArgsValidation.func1(0xc4200fa6e0, 0x0, 0xc4200fa6e0)
/Users/rconnon/go/src/github.com/fnproject/cli/main.go:144 +0x260
github.com/fnproject/cli/vendor/github.com/urfave/cli.HandleAction(0x162dbe0, 0xc42046c5a0, 0xc4200fa6e0, 0xc4200b9500, 0x0)
/Users/rconnon/go/src/github.com/fnproject/cli/vendor/github.com/urfave/cli/app.go:490 +0xc8
github.com/fnproject/cli/vendor/github.com/urfave/cli.Command.Run(0x1712497, 0x6, 0x0, 0x0, 0xc42043f210, 0x1, 0x1, 0x171c89e, 0x10, 0x0, ...)
/Users/rconnon/go/src/github.com/fnproject/cli/vendor/github.com/urfave/cli/command.go:210 +0xa36
github.com/fnproject/cli/vendor/github.com/urfave/cli.(*App).RunAsSubcommand(0xc420359380, 0xc4200fa2c0, 0x0, 0x0)
/Users/rconnon/go/src/github.com/fnproject/cli/vendor/github.com/urfave/cli/app.go:379 +0xa10
github.com/fnproject/cli/vendor/github.com/urfave/cli.Command.startApp(0x1710310, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x171f6fa, 0x13, 0x0, ...)
/Users/rconnon/go/src/github.com/fnproject/cli/vendor/github.com/urfave/cli/command.go:298 +0x8d9
github.com/fnproject/cli/vendor/github.com/urfave/cli.Command.Run(0x1710310, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x171f6fa, 0x13, 0x0, ...)
/Users/rconnon/go/src/github.com/fnproject/cli/vendor/github.com/urfave/cli/command.go:98 +0x1246
github.com/fnproject/cli/vendor/github.com/urfave/cli.(*App).Run(0xc4203591e0, 0xc4200aa0c0, 0x4, 0x4, 0x0, 0x0)
/Users/rconnon/go/src/github.com/fnproject/cli/vendor/github.com/urfave/cli/app.go:255 +0x6a0
main.main()
/Users/rconnon/go/src/github.com/fnproject/cli/main.go:166 +0x4f
darn, tried to fix this https://github.com/fnproject/cli/pull/214 there is some context there. part of the issue is that the swagger errors are kind of ugly. if we could get prettier swagger errors, we wouldn't need such intricate error handling, we could just if err != nil { return err } like normal (maybe this is better problem to solve, but I didn't see how last I looked).