Skip to content

Commit ada58b8

Browse files
committed
fix: harden termux startup arg parsing and installer checksum handling
1 parent b493897 commit ada58b8

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

cmd/main.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,20 @@ func parseFlags() ui.CLIOptions {
199199

200200
// Accept daemon address as positional argument (e.g., "derotui --testnet host:port")
201201
if opts.DaemonAddress == "" && flag.NArg() > 0 {
202-
arg := flag.Arg(0)
203-
// If it looks like a host:port or hostname, use it as daemon address
204-
if strings.Contains(arg, ":") || strings.Contains(arg, ".") {
205-
opts.DaemonAddress = arg
202+
arg := strings.TrimSpace(flag.Arg(0))
203+
if arg != "" {
204+
// Guard against shell/runtime oddities where executable path may be
205+
// passed as first positional argument (observed on some Termux setups).
206+
if strings.HasPrefix(arg, "/") {
207+
if _, err := os.Stat(arg); err == nil {
208+
return opts
209+
}
210+
}
211+
212+
// Only treat positional argument as daemon endpoint when it validates.
213+
if _, err := wallet.NormalizeDaemonAddress(arg); err == nil {
214+
opts.DaemonAddress = arg
215+
}
206216
}
207217
}
208218

0 commit comments

Comments
 (0)