vegaprotocol / vegawallet-desktop

Desktop application for Vega Protocol's wallet
MIT License
15 stars 12 forks source link

VegaHome path is not validated before it's saved #504

Closed radoslaw-szpiech closed 1 year ago

radoslaw-szpiech commented 1 year ago

Description

If VegaHome Path is changed to some inaccessible one (e.g. /some-new-system-catalog) it updates config.toml file and crashes the app. Next time the app is opened, it shows error which cannot be fixed from UI perspective. The only way to fix it is to remove config.toml file or fix VegaHome path in it.

Reproduction steps (Mac/Linux only, need investigation for Windows)

UI way:

  1. Open Vegawallet desktop app.
  2. Go to App Settings.
  3. Change Wallet Directory to invalid one e.g. /something - !remember about / at the beginning!
  4. Click Update and restart. -> App is crashed and closed with following error in console:
    
    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x100b4dcb0]

goroutine 3647 [running]: code.vegaprotocol.io/vegawallet-desktop/backend.(ServiceStarter).Info(0x0) /Users/rado/vega/vegawallet-desktop/backend/service_starter.go:113 +0x30 code.vegaprotocol.io/vegawallet-desktop/backend.(Handler).GetCurrentServiceInfo(0x140000ec620) /Users/rado/vega/vegawallet-desktop/backend/service.go:127 +0x1a8 reflect.Value.call({0x101208da0, 0x140000ec620, 0x1a13}, {0x100c5a56b, 0x4}, {0x101973300, 0x0, 0x0}) /opt/homebrew/Cellar/go/1.19.3/libexec/src/reflect/value.go:584 +0x890 reflect.Value.Call({0x101208da0, 0x140000ec620, 0x1a13}, {0x101973300, 0x0, 0x0}) /opt/homebrew/Cellar/go/1.19.3/libexec/src/reflect/value.go:368 +0x74 github.com/wailsapp/wails/v2/internal/binding.(BoundMethod).Call(0x140000ec930, {0x101973300, 0x0, 0x0}) /Users/rado/go/pkg/mod/github.com/wailsapp/wails/v2@v2.3.1/internal/binding/boundMethod.go:73 +0x27c github.com/wailsapp/wails/v2/internal/frontend/dispatcher.(Dispatcher).processCallMessage(0x14000115bc0, {0x140006b0200, 0x7b}, {0x10123ecc8, 0x1400012c180}) /Users/rado/go/pkg/mod/github.com/wailsapp/wails/v2@v2.3.1/internal/frontend/dispatcher/calls.go:45 +0x3b8 github.com/wailsapp/wails/v2/internal/frontend/dispatcher.(Dispatcher).ProcessMessage(0x14000115bc0, {0x140006b0200, 0x7b}, {0x10123ecc8, 0x1400012c180}) /Users/rado/go/pkg/mod/github.com/wailsapp/wails/v2@v2.3.1/internal/frontend/dispatcher/dispatcher.go:40 +0x18c github.com/wailsapp/wails/v2/internal/frontend/desktop/darwin.(Frontend).processMessage.func1() /Users/rado/go/pkg/mod/github.com/wailsapp/wails/v2@v2.3.1/internal/frontend/desktop/darwin/frontend.go:315 +0x74 created by github.com/wailsapp/wails/v2/internal/frontend/desktop/darwin.(*Frontend).processMessage /Users/rado/go/pkg/mod/github.com/wailsapp/wails/v2@v2.3.1/internal/frontend/desktop/darwin/frontend.go:314 +0x3e4


When the app is opened again, it results with visible error:
![image](https://user-images.githubusercontent.com/24473278/219716277-72319721-4f0b-40b0-b346-2ecf5785d329.png)

Meanwhile `config.toml` file looks like this:

LogLevel = "info" VegaHome = "/bullshit" DefaultNetwork = ""

[Telemetry] ConsentAsked = true Enabled = false



As a regular "UI" user I have no way to fix it. The only way is to delete `/Users/<user>/Library/Application Support/vega/wallet-app/config.toml` or fix VegaHome in it.

Reproducing steps shortcut (but missing the app crash)
- Just edit `config.toml` and change VegaHome to `/something`.