mirror of
https://github.com/google/gops.git
synced 2024-11-19 20:31:58 +02:00
fix out of bounds panic
This commit is contained in:
parent
60aa68d3cc
commit
89672dbe3c
2
cmd.go
2
cmd.go
@ -185,7 +185,7 @@ func targetToAddr(target string) (*net.TCPAddr, error) {
|
||||
}
|
||||
port, err := internal.GetPort(pid)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("couldn't get port for PID %s: %v", pid, err)
|
||||
return nil, fmt.Errorf("couldn't get port for PID %v: %v", pid, err)
|
||||
}
|
||||
addr, _ := net.ResolveTCPAddr("tcp", "127.0.0.1:"+port)
|
||||
return addr, nil
|
||||
|
4
main.go
4
main.go
@ -72,6 +72,10 @@ func main() {
|
||||
if !ok {
|
||||
usage("unknown subcommand")
|
||||
}
|
||||
if len(os.Args) < 3 {
|
||||
usage("Missing PID or address.")
|
||||
os.Exit(1)
|
||||
}
|
||||
addr, err := targetToAddr(os.Args[2])
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Couldn't resolve addr or pid %v to TCPAddress: %v\n", os.Args[2], err)
|
||||
|
Loading…
Reference in New Issue
Block a user